#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 O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ aio_translate(int, int);
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ err_sys(char *, char *);
int open(char *, int, ...);
int main(int argc, char *argv[]) {
  int ifd, ofd;
  if (argc != 3)
    err_quit("usage: rot13 infile outfile");
  if ((ifd = open(argv[1], O_RDONLY)) < 0)
    err_sys("can't open %s", argv[1]);
  if ((ofd = open(argv[2], O_RDWR | O_CREAT | O_TRUNC, 0644)) < 0)
    err_sys("can't create %s", argv[2]);
  aio_translate(ifd, ofd);
  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   $0x3,-0x8(%rbp)
je     116c <main+0x2c>
lea    0xe99(%rip),%rdi
call   1050 <err_quit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11a4 <main+0x64>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
mov    0x2e3c(%rip),%rax
or     (%rax),%esi
mov    0x2e2b(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    11f3 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe3c(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <aio_translate@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1158 <main+0x18>
lea    0xead(%rip),%rdi
call   1050 <err_quit@plt>
mov    0x8(%rbx),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1183 <main+0x43>
mov    0x8(%rbx),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <err_sys@plt>
mov    0x2e4e(%rip),%rax
mov    0x2e67(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%rbx),%rdi
mov    0x2e50(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11c4 <main+0x84>
mov    0x10(%rbx),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <err_sys@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1040 <aio_translate@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"usage: rot13 infile outfile\00"
@O_RDONLY = global i32 0
@.str.1 = [14 x i8] c"can't open %s\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [16 x i8] c"can't create %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @err_quit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = call i32 (i8*, i32, ...) @open(i8* %15, i32 %16)
store i32 %17, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %12
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_RDWR
%29 = load i32, i32* @O_CREAT
%30 = or i32 %28, %29
%31 = load i32, i32* @O_TRUNC
%32 = or i32 %30, %31
%33 = call i32 (i8*, i32, ...) @open(i8* %27, i32 %32, i32 420)
store i32 %33, i32* %7
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %24
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @err_sys(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %35, %24
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = call i32 @aio_translate(i32 %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"usage: rot13 infile outfile\00"
@O_RDONLY = global i32 0
@.str.1 = [14 x i8] c"can't open %s\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [16 x i8] c"can't create %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @err_quit(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 (i8*, i32, ...) @open(i8* %8, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i8*, i8** %7
%14 = tail call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %6
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDWR
%19 = load i32, i32* @O_CREAT
%20 = or i32 %19, %18
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = tail call i32 (i8*, i32, ...) @open(i8* %17, i32 %22, i32 420)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %15
%26 = load i8*, i8** %16
%27 = tail call i32 @err_sys(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %15
%29 = tail call i32 @aio_translate(i32 %10, i32 %23)
ret i32 0
}