#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 /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int lrotate(int, int);
int /*<<< orphan*/ perror(char *);
int rrotate(int, int);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  in = fopen("input.dat", "r");
  if (in == NULL) {
    perror("input.dat");
    return 1;
  }
  out = fopen("output.dat", "w");
  if (out == NULL) {
    perror("output.dat");
    return 1;
  }
  int x, n, y;
  while (fscanf(in, "%x %d", &x, &n) != EOF) {
    y = rrotate(x, n);
    fprintf(out, "rrotate(0x%x, %d) is 0x%x\n", x, n, y);
    y = lrotate(x, n);
    fprintf(out, "lrotate(0x%x, %d) is 0x%x\n", x, n, y);
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c0 <main+0x50>
lea    0xe51(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1295 <main+0x125>
lea    0xe45(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fa <main+0x8a>
lea    0xe23(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1295 <main+0x125>
jmp    11ff <main+0x8f>
mov    -0x18(%rbp),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1060 <fscanf@plt>
mov    0x2dca(%rip),%rcx
cmp    (%rcx),%rax
je     127c <main+0x10c>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1040 <rrotate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xdd5(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <lrotate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xdc8(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11ff <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1272 <main+0x102>
mov    %rax,%r14
lea    0xe6b(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     127b <main+0x10b>
mov    %rax,%rbx
lea    0xe59(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1060 <fscanf@plt>
mov    0x2e11(%rip),%r12
cmp    (%r12),%rax
je     1251 <main+0xe1>
lea    0xe35(%rip),%r13
lea    0x4(%rsp),%rbp
mov    %rsp,%r15
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1040 <rrotate@plt>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    %rbx,%rdi
lea    0xe12(%rip),%rsi
mov    %eax,%r8d
call   1070 <fprintf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1030 <lrotate@plt>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    %rbx,%rdi
lea    0xe08(%rip),%rsi
mov    %eax,%r8d
call   1070 <fprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1060 <fscanf@plt>
cmp    (%r12),%rax
jne    11f0 <main+0x80>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd87(%rip),%rdi
jmp    1282 <main+0x112>
lea    0xd8a(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
jmp    1263 <main+0xf3>

LLVM IR (-O0):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%x %d\00"
@EOF = global i64 0
@.str.5 = [27 x i8] c"rrotate(0x%x, %d) is 0x%x\0A\00"
@.str.6 = [27 x i8] c"lrotate(0x%x, %d) is 0x%x\0A\00"
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
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %50
16: ; preds = %2
%17 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %50
22: ; preds = %16
br label %23
23: ; preds = %28, %22
%24 = load i32*, i32** %6
%25 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %8, i32* %9)
%26 = load i64, i64* @EOF
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i32 @rrotate(i32 %29, i32 %30)
store i32 %31, i32* %10
%32 = load i32*, i32** %7
%33 = load i32, i32* %8
%34 = load i32, i32* %9
%35 = load i32, i32* %10
%36 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %8
%38 = load i32, i32* %9
%39 = call i32 @lrotate(i32 %37, i32 %38)
store i32 %39, i32* %10
%40 = load i32*, i32** %7
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
br label %23
45: ; preds = %23
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
store i32 0, i32* %3
br label %50
50: ; preds = %45, %20, %14
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%x %d\00"
@EOF = global i64 0
@.str.5 = [27 x i8] c"rrotate(0x%x, %d) is 0x%x\0A\00"
@.str.6 = [27 x i8] c"lrotate(0x%x, %d) is 0x%x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %39
9: ; preds = %2
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %39
14: ; preds = %9
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
%17 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %36, label %20
20: ; preds = %14, %20
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @rrotate(i32 %21, i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25, i32 %23)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 @lrotate(i32 %27, i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %30, i32 %31, i32 %29)
%33 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%34 = load i64, i64* @EOF
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %20
36: ; preds = %20, %14
%37 = call i32 @fclose(i32* %5)
%38 = call i32 @fclose(i32* %10)
br label %39
39: ; preds = %36, %12, %7
%40 = phi i32 [ 1, %7 ], [ 1, %12 ], [ 0, %36 ]
ret i32 %40
}