#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*/ memcpy_irc();
int /*<<< orphan*/ memcpy_mixed();
int /*<<< orphan*/ strncpy_irc();
int /*<<< orphan*/ strncpy_mixed();
int /*<<< orphan*/ test_strncpy();
int /*<<< orphan*/ while_irc();
int /*<<< orphan*/ while_mixed();
int main(int argc, char **argv) {
  int which = 0;
  if (argc > 1)
    which = atoi(argv[1]);
  switch (which) {
  case 0:
    test_strncpy();
    break;
  case 1:
    strncpy_mixed();
    break;
  case 2:
    memcpy_mixed();
    break;
  case 3:
    while_mixed();
    break;
  case 4:
    strncpy_irc();
    break;
  case 5:
    memcpy_irc();
    break;
  case 6:
    while_irc();
  default:
    break;
  }
  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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11b7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x6,%rax
ja     122b <main+0xab>
mov    -0x20(%rbp),%rax
lea    0xe2d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <test_strncpy@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1090 <strncpy_mixed@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1050 <memcpy_mixed@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1080 <while_mixed@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1060 <strncpy_irc@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1040 <memcpy_irc@plt>
jmp    1230 <main+0xb0>
mov    $0x0,%al
call   1070 <while_irc@plt>
jmp    1230 <main+0xb0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jl     11a6 <main+0x26>
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
cmp    $0x6,%eax
ja     11ad <main+0x2d>
mov    %eax,%eax
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1030 <test_strncpy@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1090 <strncpy_mixed@plt>
jmp    11ad <main+0x2d>
xor    %eax,%eax
call   1050 <memcpy_mixed@plt>
jmp    11ad <main+0x2d>
xor    %eax,%eax
call   1080 <while_mixed@plt>
jmp    11ad <main+0x2d>
xor    %eax,%eax
call   1060 <strncpy_irc@plt>
jmp    11ad <main+0x2d>
xor    %eax,%eax
call   1040 <memcpy_irc@plt>
jmp    11ad <main+0x2d>
xor    %eax,%eax
call   1070 <while_irc@plt>
jmp    11ad <main+0x2d>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
br label %14
14: ; preds = %9, %2
%15 = load i32, i32* %6
switch i32 %15, label %30 [
i32 0, label %16
i32 1, label %18
i32 2, label %20
i32 3, label %22
i32 4, label %24
i32 5, label %26
i32 6, label %28
]
16: ; preds = %14
%17 = call i32 (...) @test_strncpy()
br label %31
18: ; preds = %14
%19 = call i32 (...) @strncpy_mixed()
br label %31
20: ; preds = %14
%21 = call i32 (...) @memcpy_mixed()
br label %31
22: ; preds = %14
%23 = call i32 (...) @while_mixed()
br label %31
24: ; preds = %14
%25 = call i32 (...) @strncpy_irc()
br label %31
26: ; preds = %14
%27 = call i32 (...) @memcpy_irc()
br label %31
28: ; preds = %14
%29 = call i32 (...) @while_irc()
br label %30
30: ; preds = %14, %28
br label %31
31: ; preds = %30, %26, %24, %22, %20, %18, %16
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
switch i32 %7, label %22 [
i32 0, label %8
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
i32 5, label %18
i32 6, label %20
]
8: ; preds = %2, %4
%9 = tail call i32 (...) @test_strncpy()
br label %22
10: ; preds = %4
%11 = tail call i32 (...) @strncpy_mixed()
br label %22
12: ; preds = %4
%13 = tail call i32 (...) @memcpy_mixed()
br label %22
14: ; preds = %4
%15 = tail call i32 (...) @while_mixed()
br label %22
16: ; preds = %4
%17 = tail call i32 (...) @strncpy_irc()
br label %22
18: ; preds = %4
%19 = tail call i32 (...) @memcpy_irc()
br label %22
20: ; preds = %4
%21 = tail call i32 (...) @while_irc()
br label %22
22: ; preds = %20, %4, %18, %16, %14, %12, %10, %8
ret i32 0
}