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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int O_CREAT;
int O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ atoll(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  off_t off;
  if ((argc != 3) || strcmp(argv[1], "--help") == 0) {
    fprintf(stdout, "Usage: %s name offset\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  fd = open(argv[1], O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    fprintf(stderr, "error on open\n");
    exit(EXIT_FAILURE);
  }
  off = atoll(argv[2]);
  if (lseek(fd, off, SEEK_SET) == -1) {
    fprintf(stderr, "error on lseek\n");
    exit(EXIT_FAILURE);
  }
  if (write(fd, "test", 4) == -1) {
    fprintf(stderr, "error on write\n");
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


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)
jne    11ae <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <main+0x6a>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    0x2dee(%rip),%rax
or     (%rax),%esi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
mov    0x2dd4(%rip),%rax
or     (%rax),%edx
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    123d <main+0xcd>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoll@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    0x2d66(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
jne    128f <main+0x11f>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%edi
lea    0xda4(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    12d1 <main+0x161>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
lea    0xd86(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1190 <main+0x20>
mov    0x8(%rbx),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11af <main+0x3f>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe64(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1256 <main+0xe6>
mov    0x8(%rbx),%rdi
mov    0x2e3e(%rip),%rax
mov    0x2e1f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2de4(%rip),%rax
mov    0x2e05(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   1080 <open@plt>
cmp    $0xffffffff,%eax
jne    11f3 <main+0x83>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
jmp    124f <main+0xdf>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1050 <atoll@plt>
mov    0x2dbb(%rip),%rcx
mov    (%rcx),%edx
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1227 <main+0xb7>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
jmp    124f <main+0xdf>
lea    0xe0f(%rip),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1264 <main+0xf4>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@stdout = global i32 0
@.str.1 = [23 x i8] c"Usage: %s name offset\0A\00"
@EXIT_FAILURE = global i32 0
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.2 = [15 x i8] c"error on open\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [16 x i8] c"error on lseek\0A\00"
@.str.4 = [5 x i8] c"test\00"
@.str.5 = [16 x i8] c"error on write\0A\00"
@EXIT_SUCCESS = global i32 0
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 %16, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %10, %2
%17 = load i32, i32* @stdout
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %10
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_CREAT
%29 = load i32, i32* @O_RDWR
%30 = or i32 %28, %29
%31 = load i32, i32* @S_IRUSR
%32 = load i32, i32* @S_IWUSR
%33 = or i32 %31, %32
%34 = call i32 @open(i8* %27, i32 %30, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %42
37: ; preds = %24
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %24
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @atoll(i8* %45)
store i32 %46, i32* %7
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = load i32, i32* @SEEK_SET
%50 = call i32 @lseek(i32 %47, i32 %48, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %57
52: ; preds = %42
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %42
%58 = load i32, i32* %6
%59 = call i32 @write(i32 %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %66
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %57
%67 = load i32, i32* @EXIT_SUCCESS
%68 = call i32 @exit(i32 %67)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@stdout = global i32 0
@.str.1 = [23 x i8] c"Usage: %s name offset\0A\00"
@EXIT_FAILURE = global i32 0
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@stderr = global i32 0
@.str.2 = [15 x i8] c"error on open\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [16 x i8] c"error on lseek\0A\00"
@.str.4 = [5 x i8] c"test\00"
@.str.5 = [16 x i8] c"error on write\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4, %2
%10 = load i32, i32* @stdout
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = load i32, i32* @O_CREAT
%18 = load i32, i32* @O_RDWR
%19 = or i32 %18, %17
%20 = load i32, i32* @S_IRUSR
%21 = load i32, i32* @S_IWUSR
%22 = or i32 %21, %20
%23 = tail call i32 @open(i8* %16, i32 %19, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = tail call i32 @exit(i32 %28)
unreachable
30: ; preds = %15
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = tail call i32 @atoll(i8* %32)
%34 = load i32, i32* @SEEK_SET
%35 = tail call i32 @lseek(i32 %23, i32 %33, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %42
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %30
%43 = tail call i32 @write(i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = tail call i32 @exit(i32 %48)
unreachable
50: ; preds = %42
%51 = load i32, i32* @EXIT_SUCCESS
%52 = tail call i32 @exit(i32 %51)
unreachable
}