#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int add_zone(unsigned short *, int *);
int /*<<< orphan*/ read_block(int, char *);
int /*<<< orphan*/ write_block(int, char *);
void add_zone_ind(unsigned short *znr, int *corrected) {
  static char blk[(1 << 10)];
  int i, chg_blk = 0;
  int block;
  block = add_zone(znr, corrected);
  if (!block)
    return;
  read_block(block, blk);
  for (i = 0; i < ((1 << 10) >> 1); i++)
    add_zone(i + (unsigned short *)blk, &chg_blk);
  if (chg_blk)
    write_block(block, blk);
}


x86 assembly (clang, -O0):
<add_zone_ind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <add_zone@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1166 <add_zone_ind+0x36>
jmp    11cb <add_zone_ind+0x9b>
mov    -0x1c(%rbp),%edi
lea    0x2ee0(%rip),%rsi
call   1050 <read_block@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jge    11b2 <add_zone_ind+0x82>
movslq -0x14(%rbp),%rax
lea    0x2ebc(%rip),%rdi
shl    $0x1,%rax
add    %rax,%rdi
lea    -0x18(%rbp),%rsi
call   1030 <add_zone@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <add_zone_ind+0x4c>
cmpl   $0x0,-0x18(%rbp)
je     11cb <add_zone_ind+0x9b>
mov    -0x1c(%rbp),%edi
lea    0x2e8a(%rip),%rsi
call   1040 <write_block@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_zone_ind>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
call   1030 <add_zone@plt>
test   %eax,%eax
je     119f <add_zone_ind+0x6f>
mov    %eax,%r14d
lea    0x2efe(%rip),%r15
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <read_block@plt>
xor    %ebx,%ebx
lea    0x4(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r15,%rbx,1),%rdi
mov    %rbp,%rsi
call   1030 <add_zone@plt>
add    $0x2,%rbx
cmp    $0x400,%rbx
jne    1170 <add_zone_ind+0x40>
cmpl   $0x0,0x4(%rsp)
je     119f <add_zone_ind+0x6f>
lea    0x2eb9(%rip),%rsi
mov    %r14d,%edi
call   1040 <write_block@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@add_zone_ind.blk = internal global [1024 x i8] zeroinitializer
define void @add_zone_ind(i16* %0, i32* %1) {
%3 = alloca i16*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i16* %0, i16** %3
store i32* %1, i32** %4
store i32 0, i32* %6
%8 = load i16*, i16** %3
%9 = load i32*, i32** %4
%10 = call i32 @add_zone(i16* %8, i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
br label %34
14: ; preds = %2
%15 = load i32, i32* %7
%16 = call i32 @read_block(i32 %15, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @add_zone_ind.blk, i64 0, i64 0))
store i32 0, i32* %5
br label %17
17: ; preds = %25, %14
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 512
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i16, i16* bitcast ([1024 x i8]* @add_zone_ind.blk to i16*), i64 %22
%24 = call i32 @add_zone(i16* %23, i32* %6)
br label %25
25: ; preds = %20
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %17
28: ; preds = %17
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %7
%33 = call i32 @write_block(i32 %32, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @add_zone_ind.blk, i64 0, i64 0))
br label %34
34: ; preds = %13, %31, %28
ret void
}

LLVM IR (-O2):
@add_zone_ind.blk = internal global [1024 x i8] zeroinitializer
define void @add_zone_ind(i16* %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @add_zone(i16* %0, i32* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %2
%8 = tail call i32 @read_block(i32 %5, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @add_zone_ind.blk, i64 0, i64 0))
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %13, %9 ]
%11 = getelementptr inbounds i16, i16* bitcast ([1024 x i8]* @add_zone_ind.blk to i16*), i64 %10
%12 = call i32 @add_zone(i16* %11, i32* %3)
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, 512
br i1 %14, label %15, label %9
15: ; preds = %9
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @write_block(i32 %5, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @add_zone_ind.blk, i64 0, i64 0))
br label %20
20: ; preds = %15, %18, %2
ret void
}