#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 /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
size_t read(int, char *, int);
int main(int argc, char **argv, char **env) {
  int nf;
  char buf[128];
  printf("args: %s; %s\n", argv[0], argv[1]);
  nf = atoi(argv[1]);
  lseek(nf, 0, SEEK_SET);
  buf[read(nf, buf, sizeof buf)] = '\0';
  printf("%s\n", buf);
  close(nf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x1c(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1060 <read@plt>
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xa0(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    0x8(%rbx),%rdx
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x80,%edx
call   1060 <read@plt>
movb   $0x0,(%rsp,%rax,1)
lea    0xe5e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"args: %s; %s\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca [128 x i8]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i8**, i8*** %6
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %15)
%17 = load i8**, i8*** %6
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = load i32, i32* @SEEK_SET
%23 = call i32 @lseek(i32 %21, i32 0, i32 %22)
%24 = load i32, i32* %8
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%26 = call i64 @read(i32 %24, i8* %25, i32 128)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* %8
%31 = call i32 @close(i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"args: %s; %s\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %8)
%10 = load i8*, i8** %7
%11 = tail call i32 @atoi(i8* %10)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @lseek(i32 %11, i32 0, i32 %12)
%14 = call i64 @read(i32 %11, i8* %5, i32 128)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%17 = call i32 @close(i32 %11)
ret i32 0
}