#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 atoi(char *);
int /*<<< orphan*/ ece453_reg_write(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("usage: %s dmx_address dmx_value\n\r", argv[0]);
    return -1;
  }
  ece453_reg_write("/sys/kernel/ece453/dmx_addr", atoi(argv[1]));
  ece453_reg_write("/sys/kernel/ece453/dmx_data", atoi(argv[2]));
  ece453_reg_write("/sys/kernel/ece453/dmx_size", 1);
  ece453_reg_write("/sys/kernel/ece453/control", 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    116f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe9d(%rip),%rdi
call   1040 <ece453_reg_write@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe9e(%rip),%rdi
call   1040 <ece453_reg_write@plt>
lea    0xeae(%rip),%rdi
mov    $0x1,%esi
call   1040 <ece453_reg_write@plt>
lea    0xeb9(%rip),%rdi
mov    $0x1,%esi
call   1040 <ece453_reg_write@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     114f <main+0x1f>
mov    (%rbx),%rsi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
lea    0xec3(%rip),%rdi
mov    %eax,%esi
call   1040 <ece453_reg_write@plt>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
lea    0xec8(%rip),%rdi
mov    %eax,%esi
call   1040 <ece453_reg_write@plt>
lea    0xed6(%rip),%rdi
mov    $0x1,%esi
call   1040 <ece453_reg_write@plt>
lea    0xee1(%rip),%rdi
mov    $0x1,%esi
call   1040 <ece453_reg_write@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"usage: %s dmx_address dmx_value\0A\0D\00"
@.str.1 = [28 x i8] c"/sys/kernel/ece453/dmx_addr\00"
@.str.2 = [28 x i8] c"/sys/kernel/ece453/dmx_data\00"
@.str.3 = [28 x i8] c"/sys/kernel/ece453/dmx_size\00"
@.str.4 = [27 x i8] c"/sys/kernel/ece453/control\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 -1, i32* %3
br label %26
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 1)
%25 = call i32 @ece453_reg_write(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %26
26: ; preds = %13, %8
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [34 x i8] c"usage: %s dmx_address dmx_value\0A\0D\00"
@.str.1 = [28 x i8] c"/sys/kernel/ece453/dmx_addr\00"
@.str.2 = [28 x i8] c"/sys/kernel/ece453/dmx_data\00"
@.str.3 = [28 x i8] c"/sys/kernel/ece453/dmx_size\00"
@.str.4 = [27 x i8] c"/sys/kernel/ece453/control\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = tail call i32 @ece453_reg_write(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 1)
%17 = tail call i32 @ece453_reg_write(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %18
18: ; preds = %7, %4
%19 = phi i32 [ -1, %4 ], [ 0, %7 ]
ret i32 %19
}