#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 */
typedef int ssize_t;
typedef int /*<<< orphan*/ chunk;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int read(int, void *, int);
int write(int /*<<< orphan*/, void *, size_t);
int main(int argc, char *argv[]) {
  char chunk[1 + ((2047))] = {'\0'};
  ssize_t size = 0;
  ssize_t i = 0;
  int exit_code = EXIT_FAILURE;
  int log_file = 0;
  if (1 != argc) {
    (void)write(STDOUT_FILENO, "Usage: syslog\n", sizeof("Usage: syslog\n"));
    goto end;
  }
  log_file = open("/var/log/messages", O_RDONLY);
  if (-1 == log_file) {
    goto end;
  }
  do {
    size = read(log_file, (void *)chunk, sizeof(chunk));
    switch (size) {
    case 0:
      exit_code = EXIT_SUCCESS;
    case (-1):
      goto close_log;
    default:
      for (i = 0; size > i; ++i) {
        chunk[i] ^= (0xF1);
      }
      if (size != write(STDOUT_FILENO, (void *)chunk, (size_t)size)) {
        goto close_log;
      }
    }
  } while (1);
close_log:
  (void)close(log_file);
end:
  return exit_code;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
movl   $0x0,-0x814(%rbp)
movl   $0x0,-0x818(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x81c(%rbp)
movl   $0x0,-0x820(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     11d6 <main+0x86>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    $0xf,%edx
call   1030 <write@plt>
jmp    131c <main+0x1cc>
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
lea    0xe29(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x820(%rbp)
mov    $0xffffffff,%eax
cmp    -0x820(%rbp),%eax
jne    1207 <main+0xb7>
jmp    131c <main+0x1cc>
jmp    120c <main+0xbc>
mov    -0x820(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x800,%edx
call   1060 <read@plt>
mov    %eax,-0x814(%rbp)
mov    -0x814(%rbp),%eax
mov    %eax,-0x824(%rbp)
sub    $0xffffffff,%eax
je     1265 <main+0x115>
jmp    1243 <main+0xf3>
mov    -0x824(%rbp),%eax
test   %eax,%eax
jne    126a <main+0x11a>
jmp    1256 <main+0x106>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x81c(%rbp)
jmp    1311 <main+0x1c1>
movl   $0x0,-0x818(%rbp)
mov    -0x814(%rbp),%eax
cmp    -0x818(%rbp),%eax
jle    12b6 <main+0x166>
movslq -0x818(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%ecx
ff
xor    $0xf1,%ecx
mov    %cl,-0x810(%rbp,%rax,1)
mov    -0x818(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x818(%rbp)
jmp    1274 <main+0x124>
mov    -0x814(%rbp),%eax
mov    %eax,-0x828(%rbp)
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    -0x810(%rbp),%rsi
movslq -0x814(%rbp),%rdx
call   1030 <write@plt>
mov    %eax,%ecx
mov    -0x828(%rbp),%eax
cmp    %ecx,%eax
je     12f3 <main+0x1a3>
jmp    1311 <main+0x1c1>
jmp    12f8 <main+0x1a8>
jmp    12fd <main+0x1ad>
mov    $0x1,%al
test   $0x1,%al
jne    120c <main+0xbc>
jmp    130c <main+0x1bc>
jmp    1311 <main+0x1c1>
mov    -0x820(%rbp),%edi
call   1050 <close@plt>
mov    -0x81c(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%r14d
cmp    $0x1,%ebx
jne    12fb <main+0x1ab>
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
lea    0xe8a(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1329 <main+0x1d9>
mov    %eax,%r12d
mov    %rsp,%r15
movabs $0xf1f1f1f1f1f1f1f1,%rbp
f1 f1 f1
mov    0x2e36(%rip),%r13
jmp    11d7 <main+0x87>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
movslq %ebx,%rdx
mov    %r15,%rsi
call   1030 <write@plt>
cmp    %eax,%ebx
jne    1321 <main+0x1d1>
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x800,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1321 <main+0x1d1>
mov    %eax,%ebx
test   %eax,%eax
je     1317 <main+0x1c7>
jle    11c0 <main+0x70>
mov    %ebx,%eax
cmp    $0x8,%ebx
jae    1210 <main+0xc0>
xor    %ecx,%ecx
jmp    12e0 <main+0x190>
nopw   0x0(%rax,%rax,1)
cmp    $0x20,%ebx
jae    121c <main+0xcc>
xor    %ecx,%ecx
jmp    12b6 <main+0x166>
mov    %eax,%ecx
and    $0xffffffe0,%ecx
lea    -0x20(%rcx),%rsi
mov    %rsi,%rdx
shr    $0x5,%rdx
add    $0x1,%rdx
test   %rsi,%rsi
movaps 0xdc6(%rip),%xmm2
je     12f2 <main+0x1a2>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   0x0(%rax)
movaps (%rsp,%rsi,1),%xmm0
xorps  %xmm2,%xmm0
movaps 0x10(%rsp,%rsi,1),%xmm1
xorps  %xmm2,%xmm1
movaps %xmm0,(%rsp,%rsi,1)
movaps %xmm1,0x10(%rsp,%rsi,1)
movaps 0x20(%rsp,%rsi,1),%xmm0
xorps  %xmm2,%xmm0
movaps 0x30(%rsp,%rsi,1),%xmm1
xorps  %xmm2,%xmm1
movaps %xmm0,0x20(%rsp,%rsi,1)
movaps %xmm1,0x30(%rsp,%rsi,1)
add    $0x40,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1250 <main+0x100>
test   $0x1,%dl
je     12a9 <main+0x159>
movaps (%rsp,%rsi,1),%xmm0
xorps  %xmm2,%xmm0
movaps 0x10(%rsp,%rsi,1),%xmm1
xorps  %xmm2,%xmm1
movaps %xmm0,(%rsp,%rsi,1)
movaps %xmm1,0x10(%rsp,%rsi,1)
cmp    %rax,%rcx
je     11c0 <main+0x70>
test   $0x18,%al
je     12e0 <main+0x190>
mov    %rcx,%rdx
mov    %eax,%ecx
and    $0xfffffff8,%ecx
xchg   %ax,%ax
xor    %rbp,(%rsp,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    12c0 <main+0x170>
cmp    %rax,%rcx
je     11c0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
xorb   $0xf1,(%rsp,%rcx,1)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    12e0 <main+0x190>
jmp    11c0 <main+0x70>
xor    %esi,%esi
test   $0x1,%dl
jne    1291 <main+0x141>
jmp    12a9 <main+0x159>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
mov    $0xf,%edx
call   1030 <write@plt>
jmp    1329 <main+0x1d9>
mov    0x2caa(%rip),%rax
mov    (%rax),%r14d
mov    %r12d,%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [15 x i8] c"Usage: syslog\0A\00"
@.str.1 = [18 x i8] c"/var/log/messages\00"
@O_RDONLY = 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 [2048 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [2048 x i8]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %8
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %9
store i32 0, i32* %10
%13 = load i32, i32* %4
%14 = icmp ne i32 1, %13
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @STDOUT_FILENO
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 15)
br label %65
18: ; preds = %2
%19 = load i32, i32* @O_RDONLY
%20 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %19)
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = icmp eq i32 -1, %21
br i1 %22, label %23, label %24
23: ; preds = %18
br label %65
24: ; preds = %18
br label %25
25: ; preds = %60, %24
%26 = load i32, i32* %10
%27 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%28 = call i32 @read(i32 %26, i8* %27, i32 2048)
store i32 %28, i32* %7
%29 = load i32, i32* %7
switch i32 %29, label %33 [
i32 0, label %30
i32 -1, label %32
]
30: ; preds = %25
%31 = load i32, i32* @EXIT_SUCCESS
store i32 %31, i32* %9
br label %32
32: ; preds = %25, %30
br label %62
33: ; preds = %25
store i32 0, i32* %8
br label %34
34: ; preds = %46, %33
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %49
38: ; preds = %34
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = xor i32 %43, 241
%45 = trunc i32 %44 to i8
store i8 %45, i8* %41
br label %46
46: ; preds = %38
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %34
49: ; preds = %34
%50 = load i32, i32* %7
%51 = load i32, i32* @STDOUT_FILENO
%52 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = call i32 @write(i32 %51, i8* %52, i64 %54)
%56 = icmp ne i32 %50, %55
br i1 %56, label %57, label %58
57: ; preds = %49
br label %62
58: ; preds = %49
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
br i1 true, label %25, label %61
61: ; preds = %60
br label %62
62: ; preds = %61, %57, %32
%63 = load i32, i32* %10
%64 = call i32 @close(i32 %63)
br label %65
65: ; preds = %62, %23, %15
%66 = load i32, i32* %9
ret i32 %66
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@STDOUT_FILENO = global i32 0
@.str = [15 x i8] c"Usage: syslog\0A\00"
@.str.1 = [18 x i8] c"/var/log/messages\00"
@O_RDONLY = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @EXIT_FAILURE
%6 = icmp eq i32 %0, 1
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @STDOUT_FILENO
%9 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 15)
br label %111
10: ; preds = %2
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %111, label %14
14: ; preds = %10, %103
%15 = call i32 @read(i32 %12, i8* %4, i32 2048)
switch i32 %15, label %16 [
i32 0, label %94
i32 -1, label %108
]
16: ; preds = %14
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %103
18: ; preds = %16
%19 = zext i32 %15 to i64
%20 = icmp ult i32 %15, 8
br i1 %20, label %92, label %21
21: ; preds = %18
%22 = icmp ult i32 %15, 32
br i1 %22, label %78, label %23
23: ; preds = %21
%24 = and i64 %19, 4294967264
%25 = add nsw i64 %24, -32
%26 = lshr exact i64 %25, 5
%27 = add nuw nsw i64 %26, 1
%28 = and i64 %27, 1
%29 = icmp eq i64 %25, 0
br i1 %29, label %59, label %30
30: ; preds = %23
%31 = and i64 %27, 1152921504606846974
br label %32
32: ; preds = %32, %30
%33 = phi i64 [ 0, %30 ], [ %56, %32 ]
%34 = phi i64 [ 0, %30 ], [ %57, %32 ]
%35 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %33
%36 = bitcast i8* %35 to <16 x i8>*
%37 = load <16 x i8>, <16 x i8>* %36
%38 = getelementptr inbounds i8, i8* %35, i64 16
%39 = bitcast i8* %38 to <16 x i8>*
%40 = load <16 x i8>, <16 x i8>* %39
%41 = xor <16 x i8> %37, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%42 = xor <16 x i8> %40, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%43 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %43
%44 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %42, <16 x i8>* %44
%45 = or i64 %33, 32
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %45
%47 = bitcast i8* %46 to <16 x i8>*
%48 = load <16 x i8>, <16 x i8>* %47
%49 = getelementptr inbounds i8, i8* %46, i64 16
%50 = bitcast i8* %49 to <16 x i8>*
%51 = load <16 x i8>, <16 x i8>* %50
%52 = xor <16 x i8> %48, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%53 = xor <16 x i8> %51, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%54 = bitcast i8* %46 to <16 x i8>*
store <16 x i8> %52, <16 x i8>* %54
%55 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> %53, <16 x i8>* %55
%56 = add nuw i64 %33, 64
%57 = add i64 %34, 2
%58 = icmp eq i64 %57, %31
br i1 %58, label %59, label %32
59: ; preds = %32, %23
%60 = phi i64 [ 0, %23 ], [ %56, %32 ]
%61 = icmp eq i64 %28, 0
br i1 %61, label %73, label %62
62: ; preds = %59
%63 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %60
%64 = bitcast i8* %63 to <16 x i8>*
%65 = load <16 x i8>, <16 x i8>* %64
%66 = getelementptr inbounds i8, i8* %63, i64 16
%67 = bitcast i8* %66 to <16 x i8>*
%68 = load <16 x i8>, <16 x i8>* %67
%69 = xor <16 x i8> %65, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%70 = xor <16 x i8> %68, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%71 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %69, <16 x i8>* %71
%72 = bitcast i8* %66 to <16 x i8>*
store <16 x i8> %70, <16 x i8>* %72
br label %73
73: ; preds = %59, %62
%74 = icmp eq i64 %24, %19
br i1 %74, label %103, label %75
75: ; preds = %73
%76 = and i64 %19, 24
%77 = icmp eq i64 %76, 0
br i1 %77, label %92, label %78
78: ; preds = %21, %75
%79 = phi i64 [ %24, %75 ], [ 0, %21 ]
%80 = and i64 %19, 4294967288
br label %81
81: ; preds = %81, %78
%82 = phi i64 [ %79, %78 ], [ %88, %81 ]
%83 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %82
%84 = bitcast i8* %83 to <8 x i8>*
%85 = load <8 x i8>, <8 x i8>* %84
%86 = xor <8 x i8> %85, <i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15, i8 -15>
%87 = bitcast i8* %83 to <8 x i8>*
store <8 x i8> %86, <8 x i8>* %87
%88 = add nuw i64 %82, 8
%89 = icmp eq i64 %88, %80
br i1 %89, label %90, label %81
90: ; preds = %81
%91 = icmp eq i64 %80, %19
br i1 %91, label %103, label %92
92: ; preds = %18, %75, %90
%93 = phi i64 [ 0, %18 ], [ %24, %75 ], [ %80, %90 ]
br label %96
94: ; preds = %14
%95 = load i32, i32* @EXIT_SUCCESS
br label %108
96: ; preds = %92, %96
%97 = phi i64 [ %101, %96 ], [ %93, %92 ]
%98 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = xor i8 %99, -15
store i8 %100, i8* %98
%101 = add nuw nsw i64 %97, 1
%102 = icmp eq i64 %101, %19
br i1 %102, label %103, label %96
103: ; preds = %96, %73, %90, %16
%104 = load i32, i32* @STDOUT_FILENO
%105 = sext i32 %15 to i64
%106 = call i32 @write(i32 %104, i8* %4, i64 %105)
%107 = icmp eq i32 %15, %106
br i1 %107, label %14, label %108
108: ; preds = %103, %14, %94
%109 = phi i32 [ %95, %94 ], [ %5, %14 ], [ %5, %103 ]
%110 = tail call i32 @close(i32 %12)
br label %111
111: ; preds = %10, %108, %7
%112 = phi i32 [ %5, %7 ], [ %5, %10 ], [ %109, %108 ]
ret i32 %112
}