#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*/ atoi(char *);
char *get_lab(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    puts("USAGE: client <labyrinth update time(secs)>.");
  else if (argc > 2) {
    puts("USAGE: client <labyrinth update time(secs)>.");
  } else {
    int i = 0, width = 10, height = 10;
    while (1) {
      char *buf = get_lab(width, height);
      if (strcmp(buf, "no way")) {
        printf("%s\n", buf);
        sleep(atoi(argv[1]));
        for (i = 0; i <= height + 1; i++)
          printf("\033[A\033[2K");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1191 <main+0x31>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
jmp    1253 <main+0xf3>
cmpl   $0x2,-0x8(%rbp)
jle    11ac <main+0x4c>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
jmp    124e <main+0xee>
movl   $0x0,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <get_lab@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1249 <main+0xe9>
mov    -0x28(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1080 <sleep@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     1244 <main+0xe4>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1217 <main+0xb7>
jmp    1249 <main+0xe9>
jmp    11c1 <main+0x61>
jmp    1253 <main+0xf3>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1247 <main+0xe7>
mov    %rsi,%r15
lea    0xeb2(%rip),%r14
lea    0xeb2(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
mov    $0xa,%esi
call   1060 <get_lab@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    0x8(%r15),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1080 <sleep@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x30>
lea    0xdb2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"USAGE: client <labyrinth update time(secs)>.\00"
@.str.1 = [7 x i8] c"no way\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [8 x i8] c"\1B[A\1B[2K\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %48
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %47
19: ; preds = %14
store i32 0, i32* %6
store i32 10, i32* %7
store i32 10, i32* %8
br label %20
20: ; preds = %19, %46
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i8* @get_lab(i32 %21, i32 %22)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %46
27: ; preds = %20
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = call i32 @sleep(i32 %33)
store i32 0, i32* %6
br label %35
35: ; preds = %42, %27
%36 = load i32, i32* %6
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
%39 = icmp sle i32 %36, %38
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %35
45: ; preds = %35
br label %46
46: ; preds = %45, %20
br label %20
47: ; preds = %17
br label %48
48: ; preds = %47, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"USAGE: client <labyrinth update time(secs)>.\00"
@.str.1 = [7 x i8] c"no way\00"
@.str.3 = [8 x i8] c"\1B[A\1B[2K\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
br label %6
6: ; preds = %27, %4
%7 = tail call i8* @get_lab(i32 10, i32 10)
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) %7)
%12 = load i8*, i8** %5
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 @sleep(i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %10, %6
br label %6
28: ; preds = %2
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
ret i32 0
}