#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 getchar();
int /*<<< orphan*/ printf(char *, int);
int str_to_uint(char *);
int tw2_getchar_hash_value(void) {
  char value[80];
  register int i = 0;
  int c;
  printf("Input (0 <= h < %d): ", 10);
  while ((c = getchar()) != (int)'\n' && i < 80 - 2)
    value[i++] = c;
  value[i] = '\0';
  return (i == 0) ? -1 : str_to_uint(value);
}


x86 assembly (clang, -O0):
<tw2_getchar_hash_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x54(%rbp)
lea    0xeba(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x58(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x59(%rbp)
je     1174 <tw2_getchar_hash_value+0x44>
cmpl   $0x4e,-0x54(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    1184 <tw2_getchar_hash_value+0x54>
jmp    119f <tw2_getchar_hash_value+0x6f>
mov    -0x58(%rbp),%eax
mov    %al,%cl
mov    -0x54(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
cltq
mov    %cl,-0x50(%rbp,%rax,1)
jmp    1150 <tw2_getchar_hash_value+0x20>
movslq -0x54(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
cmpl   $0x0,-0x54(%rbp)
jne    11bf <tw2_getchar_hash_value+0x8f>
mov    $0xffffffff,%eax
mov    %eax,-0x60(%rbp)
jmp    11cb <tw2_getchar_hash_value+0x9b>
lea    -0x50(%rbp),%rdi
call   1040 <str_to_uint@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tw2_getchar_hash_value>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xec2(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0xffffffff,%ecx
cmp    $0xa,%eax
je     118b <tw2_getchar_hash_value+0x5b>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r14
mov    %al,(%rsp,%rbx,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     117c <tw2_getchar_hash_value+0x4c>
cmp    $0x4d,%rbx
mov    %r14,%rbx
jb     1160 <tw2_getchar_hash_value+0x30>
movb   $0x0,(%rsp,%r14,1)
mov    %rsp,%rdi
call   1040 <str_to_uint@plt>
mov    %eax,%ecx
mov    %ecx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Input (0 <= h < %d): \00"
define i32 @tw2_getchar_hash_value() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 10)
br label %5
5: ; preds = %13, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 78
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = load i32, i32* %3
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %18
store i8 %15, i8* %19
br label %5
20: ; preds = %11
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %30
27: ; preds = %20
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%29 = call i32 @str_to_uint(i8* %28)
br label %30
30: ; preds = %27, %26
%31 = phi i32 [ -1, %26 ], [ %29, %27 ]
ret i32 %31
}

LLVM IR (-O2):
@.str = [22 x i8] c"Input (0 <= h < %d): \00"
define i32 @tw2_getchar_hash_value() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 10)
%4 = tail call i32 (...) @getchar()
%5 = icmp eq i32 %4, 10
br i1 %5, label %20, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ 0, %0 ]
%8 = phi i32 [ %12, %6 ], [ %4, %0 ]
%9 = trunc i32 %8 to i8
%10 = add nuw nsw i64 %7, 1
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %7
store i8 %9, i8* %11
%12 = tail call i32 (...) @getchar()
%13 = icmp ne i32 %12, 10
%14 = icmp ult i64 %7, 77
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %6, label %16
16: ; preds = %6
%17 = and i64 %10, 4294967295
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i32 @str_to_uint(i8* %2)
br label %20
20: ; preds = %0, %16
%21 = phi i32 [ %19, %16 ], [ -1, %0 ]
ret i32 %21
}