#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 atoi(char *);
unsigned int iran32(int *);
int /*<<< orphan*/ printf(char *, int, unsigned int);
void test_iran32(int argc, char **argv) {
  int i;
  int N = 20;
  int s;
  unsigned r;
  if (argc > 1)
    N = atoi(argv[1]);
  s = -10;
  for (i = 0; i < N; i++) {
    r = iran32(&s);
    printf("0x%08x 0x%08x\n", s, r);
  }
}


x86 assembly (clang, -O0):
<test_iran32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x14,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    1160 <test_iran32+0x30>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0xfffffff6,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a6 <test_iran32+0x76>
lea    -0x1c(%rbp),%rdi
call   1030 <iran32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <test_iran32+0x3e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_iran32>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1157 <test_iran32+0x27>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
movl   $0xfffffff6,0xc(%rsp)
ff
test   %eax,%eax
jg     1164 <test_iran32+0x34>
jmp    118b <test_iran32+0x5b>
movl   $0xfffffff6,0xc(%rsp)
ff
mov    $0x14,%ebx
lea    0xc(%rsp),%r14
lea    0xe90(%rip),%r15
mov    %r14,%rdi
call   1030 <iran32@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1170 <test_iran32+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"0x%08x 0x%08x\0A\00"
define void @test_iran32(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 20, i32* %6
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
br label %16
16: ; preds = %11, %2
store i32 -10, i32* %7
store i32 0, i32* %5
br label %17
17: ; preds = %26, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = call i32 @iran32(i32* %7)
store i32 %22, i32* %8
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %17
29: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"0x%08x 0x%08x\0A\00"
define void @test_iran32(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %7, label %6
6: ; preds = %2
store i32 -10, i32* %3
br label %12
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
store i32 -10, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %6, %7
%13 = phi i32 [ 20, %6 ], [ %10, %7 ]
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ %19, %14 ], [ 0, %12 ]
%16 = call i32 @iran32(i32* %3)
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %16)
%19 = add nuw nsw i32 %15, 1
%20 = icmp eq i32 %19, %13
br i1 %20, label %21, label %14
21: ; preds = %14, %7
ret void
}