#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 EXIT_FAILURE;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("chained_if 0|1|2\n");
    return EXIT_FAILURE;
  }
  if (strcmp(argv[1], "0") == 0)
    printf("Argument is zero\n");
  else if (strcmp(argv[1], "1") == 0)
    printf("Argument is one\n");
  else if (strcmp(argv[1], "2") == 0)
    printf("Argument is two\n");
  else
    printf("Argument unknown: %s\n", argv[1]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115f <main+0x3f>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <main+0x70>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <main+0xa1>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f2 <main+0xd2>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xed>
jmp    1212 <main+0xf2>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     114d <main+0x1d>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%ebx
jmp    11c5 <main+0x95>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xea5(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a5 <main+0x75>
mov    0x8(%rbx),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ae <main+0x7e>
mov    0x8(%rbx),%rdi
lea    0xed5(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b7 <main+0x87>
mov    0x8(%rbx),%rsi
lea    0xe6a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c5 <main+0x95>
lea    0xe8e(%rip),%rdi
jmp    11be <main+0x8e>
lea    0xe75(%rip),%rdi
jmp    11be <main+0x8e>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"chained_if 0|1|2\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [18 x i8] c"Argument is zero\0A\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [17 x i8] c"Argument is one\0A\00"
@.str.5 = [2 x i8] c"2\00"
@.str.6 = [17 x i8] c"Argument is two\0A\00"
@.str.7 = [22 x i8] c"Argument unknown: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %42
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %42
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %41
27: ; preds = %19
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %40
35: ; preds = %27
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %35, %33
br label %41
41: ; preds = %40, %25
br label %42
42: ; preds = %8, %41, %17
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"1\00"
@.str.5 = [2 x i8] c"2\00"
@.str.7 = [22 x i8] c"Argument unknown: %s\0A\00"
@str = [16 x i8] c"Argument is two\00"
@str.8 = [16 x i8] c"Argument is one\00"
@str.9 = [17 x i8] c"Argument is zero\00"
@str.10 = [17 x i8] c"chained_if 0|1|2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %29
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
br label %29
20: ; preds = %14
%21 = load i8*, i8** %8
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %29
26: ; preds = %20
%27 = load i8*, i8** %8
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %18, %26, %24, %4, %12
%30 = phi i32 [ %6, %4 ], [ 0, %12 ], [ 0, %18 ], [ 0, %24 ], [ 0, %26 ]
ret i32 %30
}