#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 */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char);
int main(int argv, char **argc) {
  char temptext[10] = "XXX";
  char versionnumber = 0;
  FILE *infile;
  infile = fopen(argc[1], "r");
  fread(temptext, 3, 1, infile);
  fread(&versionnumber, 1, 1, infile);
  printf("%s is a version %d scenario\n", argc[1], versionnumber);
  return versionnumber;
}


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)
mov    0xeb3(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xeb0(%rip),%ax
mov    %ax,-0x12(%rbp)
movb   $0x0,-0x1b(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x3,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%rcx
lea    -0x1b(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5a(%rip),%rdi
movsbl -0x1b(%rbp),%edx
call   1040 <printf@plt>
movsbl -0x1b(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
movw   $0x0,0x10(%rsp)
movq   $0x585858,0x8(%rsp)
movb   $0x0,0x7(%rsp)
mov    0x8(%rsi),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    0x8(%r14),%rsi
movsbl 0x7(%rsp),%ebx
lea    0xe6c(%rip),%rdi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.temptext = [10 x i8] c"XXX\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [29 x i8] c"%s is a version %d scenario\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i8
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [10 x i8]* %6 to i8*
store i8 0, i8* %7
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %8
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %8
%16 = call i32 @fread(i8* %14, i32 3, i32 1, i32* %15)
%17 = load i32*, i32** %8
%18 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i8, i8* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8 signext %22)
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
ret i32 %25
}

LLVM IR (-O2):
@__const.main.temptext = [10 x i8] c"XXX\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [29 x i8] c"%s is a version %d scenario\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @fread(i8* %5, i32 3, i32 1, i32* %8)
%10 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %8)
%11 = load i8*, i8** %6
%12 = load i8, i8* %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8 signext %12)
%14 = sext i8 %12 to i32
ret i32 %14
}