#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 /*<<< orphan*/ classic_loop(int);
int /*<<< orphan*/ duffs_loop(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 2 || argv[1][0] != 'a' && argv[1][0] != 'b') {
    fprintf(stderr, "  %s <a|b>\n", argv[0]);
    printf("%d, %d, %d", argc < 2, argv[1][0] != 'a', argv[1][0] != 'b');
    return 1;
  }
  int n = (int)1e9L;
  printf("%d\n", n);
  if (argv[1][0] == 'a') {
    classic_loop(n);
  } else {
    duffs_loop(n);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jl     1188 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
je     11f6 <main+0xb6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
je     11f6 <main+0xb6>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x2,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0xfe>
movl   $0x3b9aca00,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    122f <main+0xef>
mov    -0x14(%rbp),%edi
call   1060 <classic_loop@plt>
jmp    1237 <main+0xf7>
mov    -0x14(%rbp),%edi
call   1030 <duffs_loop@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1181 <main+0x41>
mov    0x8(%rbx),%rax
mov    (%rax),%al
add    $0x9f,%al
cmp    $0x2,%al
jae    1181 <main+0x41>
lea    0xeb9(%rip),%rdi
xor    %ebp,%ebp
mov    $0x3b9aca00,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rax
cmpb   $0x61,(%rax)
jne    11d4 <main+0x94>
mov    $0x3b9aca00,%edi
call   1060 <classic_loop@plt>
jmp    11cb <main+0x8b>
xor    %ebp,%ebp
cmp    $0x2,%edi
setl   %bpl
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x8(%rbx),%rax
mov    (%rax),%al
xor    %edx,%edx
cmp    $0x61,%al
setne  %dl
xor    %ecx,%ecx
cmp    $0x62,%al
setne  %cl
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x3b9aca00,%edi
call   1030 <duffs_loop@plt>
jmp    11cb <main+0x8b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c" %s <a|b>\0A\00"
@.str.1 = [11 x i8] c"%d, %d, %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
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
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %25, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 97
br i1 %16, label %17, label %51
17: ; preds = %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 98
br i1 %24, label %25, label %51
25: ; preds = %17, %2
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 2
%33 = zext i1 %32 to i32
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 97
%41 = zext i1 %40 to i32
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 98
%49 = zext i1 %48 to i32
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %41, i32 %49)
store i32 1, i32* %3
br label %68
51: ; preds = %17, %9
store i32 1000000000, i32* %6
%52 = load i32, i32* %6
%53 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = getelementptr inbounds i8, i8* %56, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 97
br i1 %60, label %61, label %64
61: ; preds = %51
%62 = load i32, i32* %6
%63 = call i32 @classic_loop(i32 %62)
br label %67
64: ; preds = %51
%65 = load i32, i32* %6
%66 = call i32 @duffs_loop(i32 %65)
br label %67
67: ; preds = %64, %61
store i32 0, i32* %3
br label %68
68: ; preds = %67, %25
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c" %s <a|b>\0A\00"
@.str.1 = [11 x i8] c"%d, %d, %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = add i8 %7, -97
%9 = icmp ult i8 %8, 2
br i1 %9, label %23, label %10
10: ; preds = %4, %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = zext i1 %3 to i32
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 97
%19 = zext i1 %18 to i32
%20 = icmp ne i8 %17, 98
%21 = zext i1 %20 to i32
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %19, i32 %21)
br label %32
23: ; preds = %4
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1000000000)
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 97
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = tail call i32 @classic_loop(i32 1000000000)
br label %32
30: ; preds = %23
%31 = tail call i32 @duffs_loop(i32 1000000000)
br label %32
32: ; preds = %28, %30, %10
%33 = phi i32 [ 1, %10 ], [ 0, %30 ], [ 0, %28 ]
ret i32 %33
}