#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 EXIT_SUCCESS;
int export_gpio_pin(int);
int get_pin_value(int, int *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int set_pin_value(int, int);
int unexport_gpio_pin(int);
int main(void) {
  int pinval = 0;
  int ret1 = export_gpio_pin(1);
  int ret2 = set_pin_value(1, 1);
  int ret3 = get_pin_value(1, &pinval);
  int ret4 = unexport_gpio_pin(1);
  printf("%d %d %d %d pin val: %d\n", ret1, ret2, ret3, ret4, pinval);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x1,%edi
call   1070 <export_gpio_pin@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <set_pin_value@plt>
mov    %eax,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
call   1060 <get_pin_value@plt>
mov    %eax,-0x14(%rbp)
mov    $0x1,%edi
call   1030 <unexport_gpio_pin@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x8(%rbp),%r9d
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
mov    $0x1,%edi
call   1070 <export_gpio_pin@plt>
mov    %eax,%r14d
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <set_pin_value@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1060 <get_pin_value@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   1030 <unexport_gpio_pin@plt>
mov    0xc(%rsp),%r9d
lea    0xe5b(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1050 <printf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"%d %d %d %d pin val: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call i32 @export_gpio_pin(i32 1)
store i32 %7, i32* %3
%8 = call i32 @set_pin_value(i32 1, i32 1)
store i32 %8, i32* %4
%9 = call i32 @get_pin_value(i32 1, i32* %2)
store i32 %9, i32* %5
%10 = call i32 @unexport_gpio_pin(i32 1)
store i32 %10, i32* %6
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = load i32, i32* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12, i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}

LLVM IR (-O2):
@.str = [25 x i8] c"%d %d %d %d pin val: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @export_gpio_pin(i32 1)
%4 = tail call i32 @set_pin_value(i32 1, i32 1)
%5 = call i32 @get_pin_value(i32 1, i32* %1)
%6 = call i32 @unexport_gpio_pin(i32 1)
%7 = load i32, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4, i32 %5, i32 %6, i32 %7)
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}