#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*/ buff;

/* Variables and functions */
int getLine(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int rc;
  char buff[10];
  rc = getLine("Enter string> ", buff, sizeof(buff));
  if (rc == 1) {
    printf("\nNo input\n");
    return 1;
  }
  if (rc == 2) {
    printf("Input too long [%s]\n", buff);
    return 1;
  }
  printf("OK [%s]\n", buff);
  srand(time(NULL));
  int r = rand();
  printf("%i \n", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x12(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0xa,%edx
call   1060 <getLine@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119b <main+0x4b>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1207 <main+0xb7>
cmpl   $0x2,-0x8(%rbp)
jne    11c3 <main+0x73>
lea    -0x12(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1207 <main+0xb7>
lea    -0x12(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
lea    0x6(%rsp),%rsi
mov    $0xa,%edx
call   1070 <getLine@plt>
cmp    $0x2,%eax
je     1198 <main+0x38>
cmp    $0x1,%eax
jne    11b2 <main+0x52>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    11ec <main+0x8c>
lea    0xe70(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    11ec <main+0x8c>
lea    0xe6b(%rip),%rdi
xor    %ebx,%ebx
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xe4a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter string> \00"
@.str.1 = [11 x i8] c"\0ANo input\0A\00"
@.str.2 = [21 x i8] c"Input too long [%s]\0A\00"
@.str.3 = [9 x i8] c"OK [%s]\0A\00"
@.str.4 = [5 x i8] c"%i \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @getLine(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %5, i32 10)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %25
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 1, i32* %1
br label %25
17: ; preds = %11
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = call i32 @time(i32* null)
%21 = call i32 @srand(i32 %20)
%22 = call i32 (...) @rand()
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %23)
store i32 0, i32* %1
br label %25
25: ; preds = %17, %14, %9
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter string> \00"
@.str.2 = [21 x i8] c"Input too long [%s]\0A\00"
@.str.3 = [9 x i8] c"OK [%s]\0A\00"
@.str.4 = [5 x i8] c"%i \0A\00"
@str = [10 x i8] c"\0ANo input\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @getLine(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2, i32 10)
switch i32 %3, label %8 [
i32 1, label %4
i32 2, label %6
]
4: ; preds = %0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %14
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %14
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = call i32 (...) @rand()
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %8, %6, %4
%15 = phi i32 [ 1, %4 ], [ 1, %6 ], [ 0, %8 ]
ret i32 %15
}