#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int seconds;
  char line[128];
  char message[64];
  while (1) {
    printf("Alarm> ");
    if (fgets(line, sizeof(line), stdin) == NULL)
      exit(0);
    if (strlen(line) <= 1)
      continue;
    if (sscanf(line, "%d %64[^\n]", &seconds, message) < 2)
      fprintf(stderr, "Bad command\n");
    else {
      sleep(seconds);
      printf("(%d) %s\n", seconds, message);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2e43(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11c2 <main+0x52>
xor    %edi,%edi
call   1080 <exit@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jg     11dc <main+0x6c>
jmp    1189 <main+0x19>
lea    -0xa0(%rbp),%rdi
lea    -0xe0(%rbp),%rcx
lea    0xe17(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jge    121d <main+0xad>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
jmp    123d <main+0xcd>
mov    -0x14(%rbp),%edi
call   1090 <sleep@plt>
mov    -0x14(%rbp),%esi
lea    -0xe0(%rbp),%rdx
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1189 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e52(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x50(%rsp),%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b4 <main+0x44>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0x50(%rsp),%rbx
lea    0xe40(%rip),%r14
lea    0xe41(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    121d <main+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%edi
call   1090 <sleep@plt>
mov    0xc(%rsp),%esi
lea    0xe2c(%rip),%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ad <main+0x3d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11fe <main+0x8e>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jg     11e0 <main+0x70>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11fe <main+0x8e>

LLVM IR (-O0):
@.str = [8 x i8] c"Alarm> \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"%d %64[^\0A]\00"
@stderr = global i32 0
@.str.2 = [13 x i8] c"Bad command\0A\00"
@.str.3 = [9 x i8] c"(%d) %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %9
9: ; preds = %2, %21, %36
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %11, i32 128, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %9
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = icmp sle i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %17
br label %9
22: ; preds = %17
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%25 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %6, i8* %24)
%26 = icmp slt i32 %25, 2
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %36
30: ; preds = %22
%31 = load i32, i32* %6
%32 = call i32 @sleep(i32 %31)
%33 = load i32, i32* %6
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %33, i8* %34)
br label %36
36: ; preds = %30, %27
br label %9
}

LLVM IR (-O2):
@.str = [8 x i8] c"Alarm> \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"%d %64[^\0A]\00"
@stderr = global i32 0
@.str.2 = [13 x i8] c"Bad command\0A\00"
@.str.3 = [9 x i8] c"(%d) %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca [64 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %7, i32 128, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %29, %2
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2, %29
%16 = call i32 @strlen(i8* %7)
%17 = icmp slt i32 %16, 2
br i1 %17, label %29, label %18
18: ; preds = %15
%19 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %3, i8* %8)
%20 = icmp slt i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %29
24: ; preds = %18
%25 = load i32, i32* %3
%26 = call i32 @sleep(i32 %25)
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %27, i8* %8)
br label %29
29: ; preds = %21, %24, %15
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @stdin
%32 = call i32* @fgets(i8* %7, i32 128, i32 %31)
%33 = icmp eq i32* %32, null
br i1 %33, label %13, label %15
}