#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*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ set_overscan(int, unsigned int *);
unsigned int strtoul(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int file_desc;
  unsigned overscans[4];
  file_desc = open("/dev/vcio", 0);
  if (file_desc == -1)
    exit(1);
  if (argc == 5) {
    for (int i = 0; i < 4; i++)
      if (argc > 1 + i)
        overscans[i] = strtoul(argv[1 + i], 0, 0);
    set_overscan(file_desc, overscans);
    close(file_desc);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    118b <main+0x3b>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1209 <main+0xb9>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11ee <main+0x9e>
mov    -0x8(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    11db <main+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <strtoul@plt>
mov    %eax,%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11e0 <main+0x90>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119c <main+0x4c>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1030 <set_overscan@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9c(%rip),%rdi
xor    %esi,%esi
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11d9 <main+0x89>
cmp    $0x5,%ebp
jne    11ce <main+0x7e>
mov    %eax,%r14d
mov    0x8(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,(%rsp)
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,0x4(%rsp)
mov    0x18(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,0x8(%rsp)
mov    0x20(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,0xc(%rsp)
mov    %rsp,%rsi
mov    %r14d,%edi
call   1030 <set_overscan@plt>
mov    %r14d,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/vcio\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i32]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 5
br i1 %16, label %17, label %47
17: ; preds = %14
store i32 0, i32* %8
br label %18
18: ; preds = %38, %17
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %41
21: ; preds = %18
%22 = load i32, i32* %4
%23 = load i32, i32* %8
%24 = add nsw i32 1, %23
%25 = icmp sgt i32 %22, %24
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i8**, i8*** %5
%28 = load i32, i32* %8
%29 = add nsw i32 1, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @strtoul(i8* %32, i32 0, i32 0)
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %35
store i32 %33, i32* %36
br label %37
37: ; preds = %26, %21
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %18
41: ; preds = %18
%42 = load i32, i32* %6
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%44 = call i32 @set_overscan(i32 %42, i32* %43)
%45 = load i32, i32* %6
%46 = call i32 @close(i32 %45)
store i32 0, i32* %3
br label %47
47: ; preds = %41, %14
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/vcio\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = icmp eq i32 %0, 5
br i1 %10, label %11, label %30
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strtoul(i8* %13, i32 0, i32 0)
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 %14, i32* %15
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @strtoul(i8* %17, i32 0, i32 0)
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 %18, i32* %19
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32 @strtoul(i8* %21, i32 0, i32 0)
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 %22, i32* %23
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = tail call i32 @strtoul(i8* %25, i32 0, i32 0)
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 %26, i32* %27
%28 = call i32 @set_overscan(i32 %5, i32* %15)
%29 = call i32 @close(i32 %5)
br label %30
30: ; preds = %9, %11
ret i32 0
}