#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 /*<<< orphan*/ printUsage(char *);
int sscanf(char *, char *, int *);
void checkInput(int argc, char *argv[]) {
  if (argc != 4) {
    printUsage(argv[0]);
  }
  int count;
  for (count = 2; count < 4; count++) {
    int value;
    if (sscanf(argv[count], "%d", &value) != 1) {
      printUsage(argv[0]);
    }
  }
  if (atoi(argv[2]) < 1) {
    printUsage(argv[0]);
  }
  if (atoi(argv[3]) < 1) {
    printUsage(argv[0]);
  }
}


x86 assembly (clang, -O0):
<checkInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x4(%rbp)
je     1155 <checkInput+0x25>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <printUsage@plt>
movl   $0x2,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11aa <checkInput+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe87(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     1197 <checkInput+0x67>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <printUsage@plt>
jmp    119c <checkInput+0x6c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <checkInput+0x2c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
cmp    $0x1,%eax
jge    11cc <checkInput+0x9c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <printUsage@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
cmp    $0x1,%eax
jge    11ee <checkInput+0xbe>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <printUsage@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkInput>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1145 <checkInput+0x15>
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
mov    0x10(%rbx),%rdi
lea    0xeb0(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     1167 <checkInput+0x37>
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
mov    0x18(%rbx),%rdi
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     1189 <checkInput+0x59>
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jg     119e <checkInput+0x6e>
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jg     11b3 <checkInput+0x83>
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @checkInput(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @printUsage(i8* %12)
br label %14
14: ; preds = %9, %2
store i32 2, i32* %5
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i8**, i8*** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %18
%27 = load i8**, i8*** %4
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @printUsage(i8* %29)
br label %31
31: ; preds = %26, %18
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %15
35: ; preds = %15
%36 = load i8**, i8*** %4
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %46
41: ; preds = %35
%42 = load i8**, i8*** %4
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 @printUsage(i8* %44)
br label %46
46: ; preds = %41, %35
%47 = load i8**, i8*** %4
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
%51 = icmp slt i32 %50, 1
br i1 %51, label %52, label %57
52: ; preds = %46
%53 = load i8**, i8*** %4
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @printUsage(i8* %55)
br label %57
57: ; preds = %52, %46
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @checkInput(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 4
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @printUsage(i8* %6)
br label %8
8: ; preds = %5, %2
%9 = bitcast i32* %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = icmp eq i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = load i8*, i8** %1
%16 = call i32 @printUsage(i8* %15)
br label %17
17: ; preds = %14, %8
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%21 = icmp eq i32 %20, 1
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i8*, i8** %1
%24 = call i32 @printUsage(i8* %23)
br label %25
25: ; preds = %22, %17
%26 = load i8*, i8** %10
%27 = call i32 @atoi(i8* %26)
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %1
%31 = call i32 @printUsage(i8* %30)
br label %32
32: ; preds = %29, %25
%33 = load i8*, i8** %18
%34 = call i32 @atoi(i8* %33)
%35 = icmp slt i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %1
%38 = call i32 @printUsage(i8* %37)
br label %39
39: ; preds = %36, %32
ret void
}