#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 */
scalar_t__ strcmp(char *, char const *);
int check_args(int argc, char *argv[]) {
  const char *underscore_o = "-o";
  if (argc == 1) {
    return 1;
  } else if (strcmp(argv[1], underscore_o) == 0 && argc == 2) {
    return 2;
  } else if (strcmp(argv[1], underscore_o) == 0 && argc > 2) {
    return 3;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1140 <check_args+0x30>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <check_args+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1171 <check_args+0x61>
cmpl   $0x2,-0x8(%rbp)
jne    1171 <check_args+0x61>
movl   $0x2,-0x4(%rbp)
jmp    11a9 <check_args+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a2 <check_args+0x92>
cmpl   $0x2,-0x8(%rbp)
jle    11a2 <check_args+0x92>
movl   $0x3,-0x4(%rbp)
jmp    11a9 <check_args+0x99>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_args>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0x1,%edi
je     1168 <check_args+0x58>
mov    %rsi,%r14
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
lea    0xed2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x2,%ebx
jne    1145 <check_args+0x35>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
je     1168 <check_args+0x58>
mov    0x8(%r14),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
xor    %edx,%edx
cmp    $0x3,%ebx
lea    (%rcx,%rcx,2),%eax
cmovl  %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-o\00"
define i32 @check_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %33
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8*, i8** %6
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 2, i32* %3
br label %33
21: ; preds = %17, %10
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8*, i8** %6
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 3, i32* %3
br label %33
32: ; preds = %28, %21
store i32 0, i32* %3
br label %33
33: ; preds = %32, %31, %20, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"-o\00"
define i32 @check_args(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = icmp eq i32 %0, 2
%10 = and i1 %9, %8
br i1 %10, label %18, label %11
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = icmp sgt i32 %0, 2
%16 = and i1 %15, %14
%17 = select i1 %16, i32 3, i32 0
br label %18
18: ; preds = %11, %4, %2
%19 = phi i32 [ 1, %2 ], [ 2, %4 ], [ %17, %11 ]
ret i32 %19
}