#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 *);
int test1(int);
int main(int argc, char *argv[]) {
  int nt;
  int r1;
  if (argc == 1) {
    nt = 4;
  } else {
    nt = atoi(argv[1]);
  }
  if (nt <= 0) {
    return -1;
  }
  r1 = test1(nt);
  if (r1 < 0) {
    return -2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    114c <main+0x2c>
movl   $0x4,-0x14(%rbp)
jmp    115c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1172 <main+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <main+0x7a>
mov    -0x14(%rbp),%edi
call   1030 <test1@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1193 <main+0x73>
movl   $0xfffffffe,-0x4(%rbp)
jmp    119a <main+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %edi,%eax
mov    $0x4,%edi
cmp    $0x1,%eax
je     113c <main+0x1c>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%edi
test   %eax,%eax
jle    1149 <main+0x29>
call   1030 <test1@plt>
sar    $0x1f,%eax
and    $0xfffffffe,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 4, i32* %6
br label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%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, %10
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 -1, i32* %3
br label %27
20: ; preds = %16
%21 = load i32, i32* %6
%22 = call i32 @test1(i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -2, i32* %3
br label %27
26: ; preds = %20
store i32 0, i32* %3
br label %27
27: ; preds = %26, %25, %19
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %14, label %9
9: ; preds = %2, %4
%10 = phi i32 [ %7, %4 ], [ 4, %2 ]
%11 = tail call i32 @test1(i32 %10)
%12 = icmp slt i32 %11, 0
%13 = select i1 %12, i32 -2, i32 0
br label %14
14: ; preds = %9, %4
%15 = phi i32 [ -1, %4 ], [ %13, %9 ]
ret i32 %15
}