#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 EXIT_SUCCESS;
int atoi(char *);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int c;
  int opt;
  int key;
  opt = 0;
  if (argc > 1) {
    opt = atoi(argv[1]);
  }
  key = 3;
  if (argc > 2) {
    key = atoi(argv[2]);
  }
  c = fgetc(stdin);
  while (c != EOF) {
    switch (opt) {
    case 1:
      c -= key;
      break;
    case 0:
    default:
      c += key;
      break;
    }
    fputc(c, stdout);
    c = fgetc(stdin);
  }
  return EXIT_SUCCESS;
}


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,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1188 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
je     1214 <main+0xe4>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     11df <main+0xaf>
jmp    11be <main+0x8e>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
jne    11e4 <main+0xb4>
jmp    11cf <main+0x9f>
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <main+0xbd>
jmp    11e4 <main+0xb4>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
call   1040 <fputc@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
jmp    1199 <main+0x69>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x3,%r15d
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     116b <main+0x3b>
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
cmp    $0x2,%ebx
je     116b <main+0x3b>
mov    0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
mov    0x2e76(%rip),%r12
mov    (%r12),%edi
call   1030 <fgetc@plt>
mov    0x2e5e(%rip),%r13
cmp    0x0(%r13),%eax
je     11bb <main+0x8b>
mov    %r15d,%ebx
neg    %ebx
cmp    $0x1,%r14d
cmovne %r15d,%ebx
mov    0x2e34(%rip),%rbp
nopl   0x0(%rax)
add    %ebx,%eax
mov    0x0(%rbp),%esi
mov    %eax,%edi
call   1040 <fputc@plt>
mov    (%r12),%edi
call   1030 <fgetc@plt>
cmp    0x0(%r13),%eax
jne    11a0 <main+0x70>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %7
br label %16
16: ; preds = %11, %2
store i32 3, i32* %8
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
br label %24
24: ; preds = %19, %16
%25 = load i32, i32* @stdin
%26 = call i32 @fgetc(i32 %25)
store i32 %26, i32* %6
br label %27
27: ; preds = %42, %24
%28 = load i32, i32* %6
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %27
%32 = load i32, i32* %7
switch i32 %32, label %38 [
i32 1, label %33
i32 0, label %37
]
33: ; preds = %31
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, %34
store i32 %36, i32* %6
br label %42
37: ; preds = %31
br label %38
38: ; preds = %31, %37
%39 = load i32, i32* %8
%40 = load i32, i32* %6
%41 = add nsw i32 %40, %39
store i32 %41, i32* %6
br label %42
42: ; preds = %38, %33
%43 = load i32, i32* %6
%44 = load i32, i32* @stdout
%45 = call i32 @fputc(i32 %43, i32 %44)
%46 = load i32, i32* @stdin
%47 = call i32 @fgetc(i32 %46)
store i32 %47, i32* %6
br label %27
48: ; preds = %27
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp eq i32 %0, 2
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %13
13: ; preds = %2, %9, %4
%14 = phi i32 [ %7, %9 ], [ %7, %4 ], [ 0, %2 ]
%15 = phi i32 [ %12, %9 ], [ 3, %4 ], [ 3, %2 ]
%16 = load i32, i32* @stdin
%17 = tail call i32 @fgetc(i32 %16)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %33, label %20
20: ; preds = %13
%21 = icmp eq i32 %14, 1
%22 = sub i32 0, %15
%23 = select i1 %21, i32 %22, i32 %15
br label %24
24: ; preds = %20, %24
%25 = phi i32 [ %17, %20 ], [ %30, %24 ]
%26 = add i32 %25, %23
%27 = load i32, i32* @stdout
%28 = tail call i32 @fputc(i32 %26, i32 %27)
%29 = load i32, i32* @stdin
%30 = tail call i32 @fgetc(i32 %29)
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %24
33: ; preds = %24, %13
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}