#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 *, ...);
void kb_wait_1(void) {
  unsigned long timeout = 2;
  do {
    (1 ? printf("timeout=%ld\n", timeout) : ({
      int i = 1;
      while (1)
        while (i--)
        some_label:
          printf("error\n");
      goto some_label;
    }));
    timeout--;
  } while (timeout);
}


x86 assembly (clang, -O0):
<kb_wait_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x2,-0x8(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    112f <kb_wait_1+0x1f>
jmp    1146 <kb_wait_1+0x36>
mov    -0x8(%rbp),%rsi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1183 <kb_wait_1+0x73>
movl   $0x1,-0xc(%rbp)
jmp    1152 <kb_wait_1+0x42>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     117e <kb_wait_1+0x6e>
jmp    116b <kb_wait_1+0x5b>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1152 <kb_wait_1+0x42>
jmp    114d <kb_wait_1+0x3d>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1120 <kb_wait_1+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kb_wait_1>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    $0x2,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"timeout=%ld\0A\00"
@.str.1 = [7 x i8] c"error\0A\00"
define void @kb_wait_1() {
%1 = alloca i64
%2 = alloca i32
store i64 2, i64* %1
br label %3
3: ; preds = %21, %0
br i1 true, label %4, label %7
4: ; preds = %3
%5 = load i64, i64* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %5)
br label %18
7: ; preds = %3
store i32 1, i32* %2
br label %8
8: ; preds = %7, %16
br label %9
9: ; preds = %14, %8
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %16
13: ; preds = %9
br label %14
14: ; preds = %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %9
16: ; preds = %9
br label %8
17: ; No predecessors!
br label %18
18: ; preds = %17, %4
%19 = load i64, i64* %1
%20 = add i64 %19, -1
store i64 %20, i64* %1
br label %21
21: ; preds = %18
%22 = load i64, i64* %1
%23 = icmp ne i64 %22, 0
br i1 %23, label %3, label %24
24: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"timeout=%ld\0A\00"
define void @kb_wait_1() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 2)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 1)
ret void
}