#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_rotation(char *);
int /*<<< orphan*/ guess_and_rotate();
int /*<<< orphan*/ init_rottbl(int /*<<< orphan*/);
int /*<<< orphan*/ print_file();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc == 1) {
    guess_and_rotate();
  } else if (argc == 2) {
    init_rottbl(get_rotation(argv[1]));
    print_file();
  } else {
    (void)fprintf(stderr, "usage: caesar [rotation]\n");
    exit(EXIT_FAILURE);
  }
  if (ferror(stdin)) {
    errx(EXIT_FAILURE, "<stdin>");
  }
  (void)fflush(stdout);
  if (ferror(stdout)) {
    errx(EXIT_FAILURE, "<stdout>");
  }
  return 0;
}


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   $0x1,-0x8(%rbp)
jne    11bc <main+0x2c>
mov    $0x0,%al
call   1090 <guess_and_rotate@plt>
jmp    120e <main+0x7e>
cmpl   $0x2,-0x8(%rbp)
jne    11e6 <main+0x56>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <get_rotation@plt>
mov    %eax,%edi
call   1050 <init_rottbl@plt>
mov    $0x0,%al
call   1080 <print_file@plt>
jmp    1209 <main+0x79>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    120e <main+0x7e>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     123b <main+0xab>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
call   1040 <errx@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1276 <main+0xe6>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
call   1040 <errx@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
je     11a4 <main+0x14>
cmp    $0x1,%edi
jne    1216 <main+0x86>
xor    %eax,%eax
call   1090 <guess_and_rotate@plt>
jmp    11bb <main+0x2b>
mov    0x8(%rsi),%rdi
call   10b0 <get_rotation@plt>
mov    %eax,%edi
call   1050 <init_rottbl@plt>
xor    %eax,%eax
call   1080 <print_file@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     11e3 <main+0x53>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1040 <errx@plt>
mov    0x2dde(%rip),%rbx
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    (%rbx),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     1212 <main+0x82>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1040 <errx@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"usage: caesar [rotation]\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.1 = [8 x i8] c"<stdin>\00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"<stdout>\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 eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @guess_and_rotate()
br label %26
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @get_rotation(i8* %16)
%18 = call i32 @init_rottbl(i32 %17)
%19 = call i32 (...) @print_file()
br label %25
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %13
br label %26
26: ; preds = %25, %8
%27 = load i32, i32* @stdin
%28 = call i64 @ferror(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @errx(i32 %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %30, %26
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
%36 = load i32, i32* @stdout
%37 = call i64 @ferror(i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @errx(i32 %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %39, %33
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"usage: caesar [rotation]\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.1 = [8 x i8] c"<stdin>\00"
@stdout = global i32 0
@.str.2 = [9 x i8] c"<stdout>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %11 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32 (...) @guess_and_rotate()
br label %16
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @get_rotation(i8* %7)
%9 = tail call i32 @init_rottbl(i32 %8)
%10 = tail call i32 (...) @print_file()
br label %16
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %5, %3
%17 = load i32, i32* @stdin
%18 = tail call i64 @ferror(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @errx(i32 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %16
%24 = load i32, i32* @stdout
%25 = tail call i32 @fflush(i32 %24)
%26 = load i32, i32* @stdout
%27 = tail call i64 @ferror(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %23
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @errx(i32 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %29, %23
ret i32 0
}