#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*/ CHECK(int, int, int, int, int /*<<< orphan*/, char *);
int get_mode(int, int);
int gpio_read(int, int);
int /*<<< orphan*/ gpio_write(int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_mode(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ set_pull_up_down(int, int, int);
void t1(int pi) {
  int v;
  printf("Mode/PUD/read/write tests.\n");
  set_mode(pi, 25, 0);
  v = get_mode(pi, 25);
  CHECK(1, 1, v, 0, 0, "set mode, get mode");
  set_pull_up_down(pi, 25, 2);
  v = gpio_read(pi, 25);
  CHECK(1, 2, v, 1, 0, "set pull up down, read");
  set_pull_up_down(pi, 25, 1);
  v = gpio_read(pi, 25);
  CHECK(1, 3, v, 0, 0, "set pull up down, read");
  gpio_write(pi, 25, 0);
  v = get_mode(pi, 25);
  CHECK(1, 4, v, 1, 0, "write, get mode");
  v = gpio_read(pi, 25);
  CHECK(1, 5, v, 0, 0, "read");
  gpio_write(pi, 25, 1);
  v = gpio_read(pi, 25);
  CHECK(1, 6, v, 1, 0, "write, read");
}


x86 assembly (clang, -O0):
<t1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1050 <set_mode@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1090 <get_mode@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
xor    %r8d,%r8d
lea    0xe64(%rip),%r9
mov    %esi,%edi
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
mov    $0x2,%edx
call   1040 <set_pull_up_down@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%ecx
mov    $0x2,%esi
xor    %r8d,%r8d
lea    0xe34(%rip),%r9
mov    %ecx,%edi
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1040 <set_pull_up_down@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
lea    0xdf4(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1070 <gpio_write@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1090 <get_mode@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%ecx
mov    $0x4,%esi
xor    %r8d,%r8d
lea    0xdcd(%rip),%r9
mov    %ecx,%edi
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%edi
mov    $0x5,%esi
xor    %r8d,%r8d
lea    0xdb6(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1070 <gpio_write@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0x1,%ecx
mov    $0x6,%esi
xor    %r8d,%r8d
lea    0xd6e(%rip),%r9
mov    %ecx,%edi
call   1030 <CHECK@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t1>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xec9(%rip),%rdi
call   1050 <puts@plt>
mov    %ebx,%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1060 <set_mode@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1090 <get_mode@plt>
lea    0xe5d(%rip),%r9
mov    $0x1,%edi
mov    $0x1,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
mov    $0x2,%edx
call   1040 <set_pull_up_down@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
lea    0xe36(%rip),%r14
mov    $0x1,%edi
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1040 <set_pull_up_down@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
mov    $0x1,%edi
mov    $0x3,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
xor    %edx,%edx
call   1070 <gpio_write@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1090 <get_mode@plt>
lea    0xdda(%rip),%r9
mov    $0x1,%edi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
lea    0xdc5(%rip),%r9
mov    $0x1,%edi
mov    $0x5,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0x19,%esi
mov    $0x1,%edx
call   1070 <gpio_write@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1080 <gpio_read@plt>
lea    0xd84(%rip),%r9
mov    $0x1,%edi
mov    $0x6,%esi
mov    %eax,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <CHECK@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Mode/PUD/read/write tests.\0A\00"
@.str.1 = [19 x i8] c"set mode, get mode\00"
@.str.2 = [23 x i8] c"set pull up down, read\00"
@.str.3 = [16 x i8] c"write, get mode\00"
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [12 x i8] c"write, read\00"
define void @t1(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @set_mode(i32 %5, i32 25, i32 0)
%7 = load i32, i32* %2
%8 = call i32 @get_mode(i32 %7, i32 25)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 @CHECK(i32 1, i32 1, i32 %9, i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = call i32 @set_pull_up_down(i32 %11, i32 25, i32 2)
%13 = load i32, i32* %2
%14 = call i32 @gpio_read(i32 %13, i32 25)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = call i32 @CHECK(i32 1, i32 2, i32 %15, i32 1, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = call i32 @set_pull_up_down(i32 %17, i32 25, i32 1)
%19 = load i32, i32* %2
%20 = call i32 @gpio_read(i32 %19, i32 25)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 @CHECK(i32 1, i32 3, i32 %21, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = call i32 @gpio_write(i32 %23, i32 25, i32 0)
%25 = load i32, i32* %2
%26 = call i32 @get_mode(i32 %25, i32 25)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = call i32 @CHECK(i32 1, i32 4, i32 %27, i32 1, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* %2
%30 = call i32 @gpio_read(i32 %29, i32 25)
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = call i32 @CHECK(i32 1, i32 5, i32 %31, i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* %2
%34 = call i32 @gpio_write(i32 %33, i32 25, i32 1)
%35 = load i32, i32* %2
%36 = call i32 @gpio_read(i32 %35, i32 25)
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = call i32 @CHECK(i32 1, i32 6, i32 %37, i32 1, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"set mode, get mode\00"
@.str.2 = [23 x i8] c"set pull up down, read\00"
@.str.3 = [16 x i8] c"write, get mode\00"
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [12 x i8] c"write, read\00"
@str = [27 x i8] c"Mode/PUD/read/write tests.\00"
define void @t1(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @set_mode(i32 %0, i32 25, i32 0)
%4 = tail call i32 @get_mode(i32 %0, i32 25)
%5 = tail call i32 @CHECK(i32 1, i32 1, i32 %4, i32 0, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @set_pull_up_down(i32 %0, i32 25, i32 2)
%7 = tail call i32 @gpio_read(i32 %0, i32 25)
%8 = tail call i32 @CHECK(i32 1, i32 2, i32 %7, i32 1, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @set_pull_up_down(i32 %0, i32 25, i32 1)
%10 = tail call i32 @gpio_read(i32 %0, i32 25)
%11 = tail call i32 @CHECK(i32 1, i32 3, i32 %10, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @gpio_write(i32 %0, i32 25, i32 0)
%13 = tail call i32 @get_mode(i32 %0, i32 25)
%14 = tail call i32 @CHECK(i32 1, i32 4, i32 %13, i32 1, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @gpio_read(i32 %0, i32 25)
%16 = tail call i32 @CHECK(i32 1, i32 5, i32 %15, i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 @gpio_write(i32 %0, i32 25, i32 1)
%18 = tail call i32 @gpio_read(i32 %0, i32 25)
%19 = tail call i32 @CHECK(i32 1, i32 6, i32 %18, i32 1, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
ret void
}