#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 EOF;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getchar();
scalar_t__ isascii(int);
scalar_t__ islower(int);
scalar_t__ isupper(int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
void printit(char *arg) {
  int ch, rot;
  if ((rot = atoi(arg)) < 0) {
    (void)fprintf(stderr, "caesar: bad rotation value.\n");
    exit(1);
  }
  while ((ch = getchar()) != EOF)
    putchar(isascii(ch) ? (isupper(ch)   ? ('A' + (ch - 'A' + rot) % 26)
                           : islower(ch) ? ('a' + (ch - 'a' + rot) % 26)
                                         : ch)
                        : ch);
  exit(0);
}


x86 assembly (clang, -O0):
<printit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11c0 <printit+0x40>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11c5 <printit+0x45>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e12(%rip),%rcx
cmp    (%rcx),%eax
je     127d <printit+0xfd>
mov    -0xc(%rbp),%edi
call   10a0 <isascii@plt>
cmp    $0x0,%rax
je     1267 <printit+0xe7>
mov    -0xc(%rbp),%edi
call   1070 <isupper@plt>
cmp    $0x0,%rax
je     1220 <printit+0xa0>
mov    -0xc(%rbp),%eax
sub    $0x41,%eax
add    -0x10(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x41,%eax
mov    %eax,-0x14(%rbp)
jmp    125c <printit+0xdc>
mov    -0xc(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1250 <printit+0xd0>
mov    -0xc(%rbp),%eax
sub    $0x61,%eax
add    -0x10(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x61,%eax
mov    %eax,-0x18(%rbp)
jmp    1256 <printit+0xd6>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    126d <printit+0xed>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    11c5 <printit+0x45>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<printit>:
push   %r15
push   %r14
push   %rbx
call   1080 <atoi@plt>
test   %eax,%eax
jns    11ad <printit+0x2d>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e2a(%rip),%r15
cmp    (%r15),%eax
jne    11ca <printit+0x4a>
xor    %edi,%edi
call   1090 <exit@plt>
mov    %eax,%ebx
jmp    1211 <printit+0x91>
xchg   %ax,%ax
lea    (%rbx,%r14,1),%eax
add    $0xffffffbf,%eax
movslq %eax,%rbx
imul   $0x4ec4ec4f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%ebx
add    $0x41,%ebx
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r15),%eax
je     11c3 <printit+0x43>
mov    %ebx,%edi
call   10a0 <isascii@plt>
test   %rax,%rax
je     11fb <printit+0x7b>
mov    %ebx,%edi
call   1070 <isupper@plt>
test   %rax,%rax
jne    11d0 <printit+0x50>
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     11fb <printit+0x7b>
lea    (%rbx,%r14,1),%eax
add    $0xffffff9f,%eax
movslq %eax,%rbx
imul   $0x4ec4ec4f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%ebx
add    $0x61,%ebx
jmp    11fb <printit+0x7b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"caesar: bad rotation value.\0A\00"
@EOF = global i32 0
define void @printit(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @atoi(i8* %5)
store i32 %6, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
br label %13
13: ; preds = %51, %12
%14 = call i32 (...) @getchar()
store i32 %14, i32* %3
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %55
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i64 @isascii(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load i32, i32* %3
%23 = call i64 @isupper(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 65
%28 = load i32, i32* %4
%29 = add nsw i32 %27, %28
%30 = srem i32 %29, 26
%31 = add nsw i32 65, %30
br label %47
32: ; preds = %21
%33 = load i32, i32* %3
%34 = call i64 @islower(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %3
%38 = sub nsw i32 %37, 97
%39 = load i32, i32* %4
%40 = add nsw i32 %38, %39
%41 = srem i32 %40, 26
%42 = add nsw i32 97, %41
br label %45
43: ; preds = %32
%44 = load i32, i32* %3
br label %45
45: ; preds = %43, %36
%46 = phi i32 [ %42, %36 ], [ %44, %43 ]
br label %47
47: ; preds = %45, %25
%48 = phi i32 [ %31, %25 ], [ %46, %45 ]
br label %51
49: ; preds = %17
%50 = load i32, i32* %3
br label %51
51: ; preds = %49, %47
%52 = phi i32 [ %48, %47 ], [ %50, %49 ]
%53 = trunc i32 %52 to i8
%54 = call i32 @putchar(i8 signext %53)
br label %13
55: ; preds = %13
%56 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"caesar: bad rotation value.\0A\00"
@EOF = global i32 0
define void @printit(i8* nocapture %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %39, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %4, %32
%13 = phi i32 [ %36, %32 ], [ %5, %4 ]
%14 = tail call i64 @isascii(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %12
%17 = tail call i64 @isupper(i32 %13)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = add i32 %13, %2
%21 = add i32 %20, -65
%22 = srem i32 %21, 26
%23 = add nsw i32 %22, 65
br label %32
24: ; preds = %16
%25 = tail call i64 @islower(i32 %13)
%26 = icmp eq i64 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = add i32 %13, %2
%29 = add i32 %28, -97
%30 = srem i32 %29, 26
%31 = add nsw i32 %30, 97
br label %32
32: ; preds = %12, %24, %19, %27
%33 = phi i32 [ %23, %19 ], [ %31, %27 ], [ %13, %24 ], [ %13, %12 ]
%34 = trunc i32 %33 to i8
%35 = tail call i32 @putchar(i8 signext %34)
%36 = tail call i32 (...) @getchar()
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %12
39: ; preds = %32, %4
%40 = tail call i32 @exit(i32 0)
unreachable
}