#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*/ printf(char *, int);
scalar_t__ waitForInterrupt(int, int);
void *interrupt(void *gpio_void_ptr) {
  int i = 0;
  int gpio = *(int *)gpio_void_ptr;
  while (++i < 20) {
    if (waitForInterrupt(gpio, 1000) > 0) {
      printf(">>Interrupt on GPIO %d\n", gpio);
    } else {
      printf("  Timeout on GPIO %d\n", gpio);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<interrupt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x14,%eax
jge    118d <interrupt+0x6d>
mov    -0x10(%rbp),%edi
mov    $0x3e8,%esi
call   1040 <waitForInterrupt@plt>
cmp    $0x0,%rax
jle    1179 <interrupt+0x59>
mov    -0x10(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    1188 <interrupt+0x68>
mov    -0x10(%rbp),%esi
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    113c <interrupt+0x1c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interrupt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%ebx
mov    $0x13,%ebp
lea    0xecb(%rip),%r14
lea    0xedc(%rip),%r15
nopl   0x0(%rax)
mov    %ebx,%edi
mov    $0x3e8,%esi
call   1040 <waitForInterrupt@plt>
test   %rax,%rax
mov    %r15,%rdi
cmovg  %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1140 <interrupt+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c">>Interrupt on GPIO %d\0A\00"
@.str.1 = [22 x i8] c" Timeout on GPIO %d\0A\00"
define i8* @interrupt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
store i32 %7, i32* %4
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i32, i32* %4
%14 = call i64 @waitForInterrupt(i32 %13, i32 1000)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %4
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %22
19: ; preds = %12
%20 = load i32, i32* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %16
br label %8
23: ; preds = %8
ret i8* null
}

LLVM IR (-O2):
@.str = [24 x i8] c">>Interrupt on GPIO %d\0A\00"
@.str.1 = [22 x i8] c" Timeout on GPIO %d\0A\00"
define noalias i8* @interrupt(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 1, %1 ], [ %10, %4 ]
%6 = tail call i64 @waitForInterrupt(i32 %3, i32 1000)
%7 = icmp sgt i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 @printf(i8* %8, i32 %3)
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, 20
br i1 %11, label %12, label %4
12: ; preds = %4
ret i8* null
}