#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*/ init_gpio(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int system(char *);
int main(void) {
  char command[120];
  int i;
  typedef struct {
    int header;
    int pin;
    int gpio;
  } _GPIO;
  static _GPIO chan[16] = {{8, 27, 86}, {8, 28, 88}, {8, 29, 87}, {8, 30, 89},
                           {8, 31, 10}, {8, 32, 11}, {8, 33, 9},  {8, 34, 81},
                           {8, 35, 8},  {8, 36, 80}, {8, 37, 78}, {8, 38, 79},
                           {8, 39, 86}, {8, 40, 77}, {8, 41, 74}, {8, 42, 75}};
  static _GPIO heart[4] = {{8, 7, 66}, {8, 9, 67}, {8, 8, 69}, {8, 10, 68}};
  printf("\n *********\n gpio test started\n");
  printf("starting initializations\n");
  for (i = 0; i < 16; i++) {
    init_gpio(chan[i].gpio);
  }
  for (i = 0; i < 4; i++) {
    init_gpio(heart[i].gpio);
  }
  printf("\ndone with initializations\ntest pins\n");
  for (i = 0; i < 16; i++) {
    sprintf(command, "echo 1 > /sys/class/gpio/gpio%i/value", chan[i].gpio);
    printf("system command %s returned %i\n", command, system(command));
  }
  for (i = 0; i < 4; i++) {
    sprintf(command, "echo 1 > /sys/class/gpio/gpio%i/value", heart[i].gpio);
    printf("system command %s returned %i\n", command, system(command));
  }
  printf("normal termination\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x10,-0x84(%rbp)
jge    11b6 <main+0x76>
movslq -0x84(%rbp),%rcx
lea    0x2ebd(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edi
call   1050 <init_gpio@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1178 <main+0x38>
movl   $0x0,-0x84(%rbp)
cmpl   $0x4,-0x84(%rbp)
jge    11fe <main+0xbe>
movslq -0x84(%rbp),%rcx
lea    0x2f35(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edi
call   1050 <init_gpio@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11c0 <main+0x80>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x10,-0x84(%rbp)
jge    128a <main+0x14a>
lea    -0x80(%rbp),%rdi
movslq -0x84(%rbp),%rcx
lea    0x2e1b(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edx
lea    0xe1a(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1216 <main+0xd6>
movl   $0x0,-0x84(%rbp)
cmpl   $0x4,-0x84(%rbp)
jge    1308 <main+0x1c8>
lea    -0x80(%rbp),%rdi
movslq -0x84(%rbp),%rcx
lea    0x2e5d(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edx
lea    0xd9c(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1294 <main+0x154>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xf9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x56,%edi
call   1060 <init_gpio@plt>
mov    $0x58,%edi
call   1060 <init_gpio@plt>
mov    $0x57,%edi
call   1060 <init_gpio@plt>
mov    $0x59,%edi
call   1060 <init_gpio@plt>
mov    $0xa,%edi
call   1060 <init_gpio@plt>
mov    $0xb,%edi
call   1060 <init_gpio@plt>
mov    $0x9,%edi
call   1060 <init_gpio@plt>
mov    $0x51,%edi
call   1060 <init_gpio@plt>
mov    $0x8,%edi
call   1060 <init_gpio@plt>
mov    $0x50,%edi
call   1060 <init_gpio@plt>
mov    $0x4e,%edi
call   1060 <init_gpio@plt>
mov    $0x4f,%edi
call   1060 <init_gpio@plt>
mov    $0x56,%edi
call   1060 <init_gpio@plt>
mov    $0x4d,%edi
call   1060 <init_gpio@plt>
mov    $0x4a,%edi
call   1060 <init_gpio@plt>
mov    $0x4b,%edi
call   1060 <init_gpio@plt>
mov    $0x42,%edi
call   1060 <init_gpio@plt>
mov    $0x43,%edi
call   1060 <init_gpio@plt>
mov    $0x45,%edi
call   1060 <init_gpio@plt>
mov    $0x44,%edi
call   1060 <init_gpio@plt>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x8,%ebx
lea    0xda8(%rip),%r13
lea    0xe61(%rip),%r14
mov    %rsp,%r12
lea    0xe7d(%rip),%r15
nopl   0x0(%rax)
mov    (%rbx,%r13,1),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <sprintf@plt>
mov    %r12,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xc,%rbx
cmp    $0xc8,%rbx
jne    1270 <main+0x120>
lea    0xe16(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x42,%edx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe1a(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x43,%edx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x45,%edx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x44,%edx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct._GPIO = type { i32, i32, i32 }
@main.chan = internal global [16 x %struct._GPIO] [%struct._GPIO { i32 8, i32 27, i32 86 }, %struct._GPIO { i32 8, i32 28, i32 88 }, %struct._GPIO { i32 8, i32 29, i32 87 }, %struct._GPIO { i32 8, i32 30, i32 89 }, %struct._GPIO { i32 8, i32 31, i32 10 }, %struct._GPIO { i32 8, i32 32, i32 11 }, %struct._GPIO { i32 8, i32 33, i32 9 }, %struct._GPIO { i32 8, i32 34, i32 81 }, %struct._GPIO { i32 8, i32 35, i32 8 }, %struct._GPIO { i32 8, i32 36, i32 80 }, %struct._GPIO { i32 8, i32 37, i32 78 }, %struct._GPIO { i32 8, i32 38, i32 79 }, %struct._GPIO { i32 8, i32 39, i32 86 }, %struct._GPIO { i32 8, i32 40, i32 77 }, %struct._GPIO { i32 8, i32 41, i32 74 }, %struct._GPIO { i32 8, i32 42, i32 75 }]
@main.heart = internal global [4 x %struct._GPIO] [%struct._GPIO { i32 8, i32 7, i32 66 }, %struct._GPIO { i32 8, i32 9, i32 67 }, %struct._GPIO { i32 8, i32 8, i32 69 }, %struct._GPIO { i32 8, i32 10, i32 68 }]
@.str = [32 x i8] c"\0A *********\0A gpio test started\0A\00"
@.str.1 = [26 x i8] c"starting initializations\0A\00"
@.str.2 = [38 x i8] c"\0Adone with initializations\0Atest pins\0A\00"
@.str.3 = [38 x i8] c"echo 1 > /sys/class/gpio/gpio%i/value\00"
@.str.4 = [31 x i8] c"system command %s returned %i\0A\00"
@.str.5 = [20 x i8] c"normal termination\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [120 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16 x %struct._GPIO], [16 x %struct._GPIO]* @main.chan, i64 0, i64 %11
%13 = getelementptr inbounds %struct._GPIO, %struct._GPIO* %12, i32 0, i32 2
%14 = load i32, i32* %13
%15 = call i32 @init_gpio(i32 %14)
br label %16
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %6
19: ; preds = %6
store i32 0, i32* %3
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x %struct._GPIO], [4 x %struct._GPIO]* @main.heart, i64 0, i64 %25
%27 = getelementptr inbounds %struct._GPIO, %struct._GPIO* %26, i32 0, i32 2
%28 = load i32, i32* %27
%29 = call i32 @init_gpio(i32 %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %20
33: ; preds = %20
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %35
35: ; preds = %50, %33
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 16
br i1 %37, label %38, label %53
38: ; preds = %35
%39 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [16 x %struct._GPIO], [16 x %struct._GPIO]* @main.chan, i64 0, i64 %41
%43 = getelementptr inbounds %struct._GPIO, %struct._GPIO* %42, i32 0, i32 2
%44 = load i32, i32* %43
%45 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%47 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%48 = call i32 @system(i8* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %46, i32 %48)
br label %50
50: ; preds = %38
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %35
53: ; preds = %35
store i32 0, i32* %3
br label %54
54: ; preds = %69, %53
%55 = load i32, i32* %3
%56 = icmp slt i32 %55, 4
br i1 %56, label %57, label %72
57: ; preds = %54
%58 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [4 x %struct._GPIO], [4 x %struct._GPIO]* @main.heart, i64 0, i64 %60
%62 = getelementptr inbounds %struct._GPIO, %struct._GPIO* %61, i32 0, i32 2
%63 = load i32, i32* %62
%64 = call i32 @sprintf(i8* %58, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%66 = getelementptr inbounds [120 x i8], [120 x i8]* %2, i64 0, i64 0
%67 = call i32 @system(i8* %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %65, i32 %67)
br label %69
69: ; preds = %57
%70 = load i32, i32* %3
%71 = add nsw i32 %70, 1
store i32 %71, i32* %3
br label %54
72: ; preds = %54
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct._GPIO = type { i32, i32, i32 }
@main.chan = internal unnamed_addr constant [16 x %struct._GPIO] [%struct._GPIO { i32 8, i32 27, i32 86 }, %struct._GPIO { i32 8, i32 28, i32 88 }, %struct._GPIO { i32 8, i32 29, i32 87 }, %struct._GPIO { i32 8, i32 30, i32 89 }, %struct._GPIO { i32 8, i32 31, i32 10 }, %struct._GPIO { i32 8, i32 32, i32 11 }, %struct._GPIO { i32 8, i32 33, i32 9 }, %struct._GPIO { i32 8, i32 34, i32 81 }, %struct._GPIO { i32 8, i32 35, i32 8 }, %struct._GPIO { i32 8, i32 36, i32 80 }, %struct._GPIO { i32 8, i32 37, i32 78 }, %struct._GPIO { i32 8, i32 38, i32 79 }, %struct._GPIO { i32 8, i32 39, i32 86 }, %struct._GPIO { i32 8, i32 40, i32 77 }, %struct._GPIO { i32 8, i32 41, i32 74 }, %struct._GPIO { i32 8, i32 42, i32 75 }]
@.str.3 = [38 x i8] c"echo 1 > /sys/class/gpio/gpio%i/value\00"
@.str.4 = [31 x i8] c"system command %s returned %i\0A\00"
@str = [31 x i8] c"\0A *********\0A gpio test started\00"
@str.6 = [25 x i8] c"starting initializations\00"
@str.7 = [37 x i8] c"\0Adone with initializations\0Atest pins\00"
@str.8 = [19 x i8] c"normal termination\00"
define i32 @main() {
%1 = alloca [120 x i8]
%2 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @init_gpio(i32 86)
%6 = tail call i32 @init_gpio(i32 88)
%7 = tail call i32 @init_gpio(i32 87)
%8 = tail call i32 @init_gpio(i32 89)
%9 = tail call i32 @init_gpio(i32 10)
%10 = tail call i32 @init_gpio(i32 11)
%11 = tail call i32 @init_gpio(i32 9)
%12 = tail call i32 @init_gpio(i32 81)
%13 = tail call i32 @init_gpio(i32 8)
%14 = tail call i32 @init_gpio(i32 80)
%15 = tail call i32 @init_gpio(i32 78)
%16 = tail call i32 @init_gpio(i32 79)
%17 = tail call i32 @init_gpio(i32 86)
%18 = tail call i32 @init_gpio(i32 77)
%19 = tail call i32 @init_gpio(i32 74)
%20 = tail call i32 @init_gpio(i32 75)
%21 = tail call i32 @init_gpio(i32 66)
%22 = tail call i32 @init_gpio(i32 67)
%23 = tail call i32 @init_gpio(i32 69)
%24 = tail call i32 @init_gpio(i32 68)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %26
26: ; preds = %0, %26
%27 = phi i64 [ 0, %0 ], [ %33, %26 ]
%28 = getelementptr inbounds [16 x %struct._GPIO], [16 x %struct._GPIO]* @main.chan, i64 0, i64 %27, i32 2
%29 = load i32, i32* %28
%30 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = call i32 @system(i8* %2)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %31)
%33 = add nuw nsw i64 %27, 1
%34 = icmp eq i64 %33, 16
br i1 %34, label %35, label %26
35: ; preds = %26
%36 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 66)
%37 = call i32 @system(i8* %2)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %37)
%39 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 67)
%40 = call i32 @system(i8* %2)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %40)
%42 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 69)
%43 = call i32 @system(i8* %2)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %43)
%45 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 68)
%46 = call i32 @system(i8* %2)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %46)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}