#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__ equal_str(char *, char *);
int /*<<< orphan*/ init_callbacks(int (*)(int, int));
int /*<<< orphan*/ printf(char *, int);
int stub1(int, int);
int stub2(int, int);
int stub3(int, int);
int main(int argc, char *argv[]) {
  int retval = 0;
  int (*cb[3])(int, int);
  init_callbacks(&cb);
  if (argc == 1) {
  } else if (argc == 2) {
    if (equal_str(argv[1], "one")) {
      retval = cb[0](argc + 2, argc);
    } else if (equal_str(argv[1], "two")) {
      retval = cb[1](argc + 3, argc);
    } else if (equal_str(argv[1], "three")) {
      retval = cb[2](argc + 4, argc);
    } else {
    }
  }
  printf("Final retval=%d\n", retval);
  return retval;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <init_callbacks@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1165 <main+0x35>
jmp    1227 <main+0xf7>
cmpl   $0x2,-0x8(%rbp)
jne    1222 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe82(%rip),%rsi
call   1050 <equal_str@plt>
cmp    $0x0,%rax
je     11a4 <main+0x74>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
call   *%rax
mov    %eax,-0x14(%rbp)
jmp    121d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1050 <equal_str@plt>
cmp    $0x0,%rax
je     11d9 <main+0xa9>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%edi
add    $0x3,%edi
mov    -0x8(%rbp),%esi
call   *%rax
mov    %eax,-0x14(%rbp)
jmp    1218 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1050 <equal_str@plt>
cmp    $0x0,%rax
je     120e <main+0xde>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%edi
add    $0x4,%edi
mov    -0x8(%rbp),%esi
call   *%rax
mov    %eax,-0x14(%rbp)
jmp    1213 <main+0xe3>
jmp    1213 <main+0xe3>
jmp    1218 <main+0xe8>
jmp    121d <main+0xed>
jmp    1222 <main+0xf2>
jmp    1227 <main+0xf7>
mov    -0x14(%rbp),%esi
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rdi
call   1030 <init_callbacks@plt>
xor    %ebx,%ebx
cmp    $0x2,%ebp
jne    11ba <main+0x8a>
mov    0x8(%r14),%rdi
lea    0xea9(%rip),%rsi
call   1050 <equal_str@plt>
test   %rax,%rax
je     1170 <main+0x40>
mov    $0x4,%edi
mov    $0x2,%esi
call   *(%rsp)
jmp    11b8 <main+0x88>
mov    0x8(%r14),%rdi
lea    0xe89(%rip),%rsi
call   1050 <equal_str@plt>
test   %rax,%rax
je     1195 <main+0x65>
mov    $0x5,%edi
mov    $0x2,%esi
call   *0x8(%rsp)
jmp    11b8 <main+0x88>
mov    0x8(%r14),%rdi
lea    0xe68(%rip),%rsi
call   1050 <equal_str@plt>
test   %rax,%rax
je     11ba <main+0x8a>
mov    $0x6,%edi
mov    $0x2,%esi
call   *0x10(%rsp)
mov    %eax,%ebx
lea    0xe4d(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"one\00"
@.str.1 = [4 x i8] c"two\00"
@.str.2 = [6 x i8] c"three\00"
@.str.3 = [17 x i8] c"Final retval=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i32 (i32, i32)*]
%4 = bitcast [3 x i32 (i32, i32)*]* %3 to i8*
%5 = bitcast [3 x i32 (i32, i32)*]* %3 to i32 (i32, i32)*
%6 = call i32 @init_callbacks(i32 (i32, i32)* %5)
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %33
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @equal_str(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = getelementptr inbounds [3 x i32 (i32, i32)*], [3 x i32 (i32, i32)*]* %3, i64 0, i64 0
%15 = load i32 (i32, i32)*, i32 (i32, i32)** %14
%16 = call i32 %15(i32 4, i32 2)
br label %33
17: ; preds = %8
%18 = load i8*, i8** %9
%19 = call i64 @equal_str(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = getelementptr inbounds [3 x i32 (i32, i32)*], [3 x i32 (i32, i32)*]* %3, i64 0, i64 1
%23 = load i32 (i32, i32)*, i32 (i32, i32)** %22
%24 = call i32 %23(i32 5, i32 2)
br label %33
25: ; preds = %17
%26 = load i8*, i8** %9
%27 = call i64 @equal_str(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = getelementptr inbounds [3 x i32 (i32, i32)*], [3 x i32 (i32, i32)*]* %3, i64 0, i64 2
%31 = load i32 (i32, i32)*, i32 (i32, i32)** %30
%32 = call i32 %31(i32 6, i32 2)
br label %33
33: ; preds = %21, %25, %29, %13, %2
%34 = phi i32 [ %16, %13 ], [ %24, %21 ], [ %32, %29 ], [ 0, %25 ], [ 0, %2 ]
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %34)
ret i32 %34
}