#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*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ video_set_cursor(int /*<<< orphan*/, int /*<<< orphan*/);
int getmessage(int interval) {
  int c;
  if (interval == 0)
    return 0;
  video_set_cursor(0, 0);
  fprintf(stderr, "\n(%d):", interval);
  scanf("%d", &c);
  return c;
}


x86 assembly (clang, -O0):
<getmessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1151 <getmessage+0x21>
movl   $0x0,-0x4(%rbp)
jmp    1188 <getmessage+0x58>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <video_set_cursor@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe8e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmessage>:
test   %edi,%edi
je     1176 <getmessage+0x46>
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <video_set_cursor@plt>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
lea    0xea5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"\0A(%d):\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getmessage(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %15
8: ; preds = %1
%9 = call i32 @video_set_cursor(i32 0, i32 0)
%10 = load i32, i32* @stderr
%11 = load i32, i32* %3
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
store i32 %14, i32* %2
br label %15
15: ; preds = %8, %7
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"\0A(%d):\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @getmessage(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i32 %0, 0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = tail call i32 @video_set_cursor(i32 0, i32 0)
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
br label %11
11: ; preds = %1, %5
%12 = phi i32 [ %10, %5 ], [ 0, %1 ]
ret i32 %12
}