#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int GetThreadsFromUser(void) {
  int c;
  while ((c = getchar()) != '\n' && c != EOF)
    ;
  int count = -1;
  printf("Please give number of threads");
  count = getchar();
  count = count - '0';
  printf("You entered: %d\n", count);
  return count;
}


x86 assembly (clang, -O0):
<GetThreadsFromUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x9(%rbp)
je     1154 <GetThreadsFromUser+0x34>
mov    -0x4(%rbp),%eax
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1164 <GetThreadsFromUser+0x44>
jmp    1169 <GetThreadsFromUser+0x49>
jmp    1128 <GetThreadsFromUser+0x8>
movl   $0xffffffff,-0x8(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetThreadsFromUser>:
push   %rbx
mov    0x2ec0(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1140 <GetThreadsFromUser+0x20>
cmp    (%rbx),%eax
jne    1130 <GetThreadsFromUser+0x10>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
add    $0xffffffd0,%ebx
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [30 x i8] c"Please give number of threads\00"
@.str.1 = [17 x i8] c"You entered: %d\0A\00"
define i32 @GetThreadsFromUser() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %12, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %1
%5 = icmp ne i32 %4, 10
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* %1
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br label %10
10: ; preds = %6, %3
%11 = phi i1 [ false, %3 ], [ %9, %6 ]
br i1 %11, label %12, label %13
12: ; preds = %10
br label %3
13: ; preds = %10
store i32 -1, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @getchar()
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 48
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [30 x i8] c"Please give number of threads\00"
@.str.1 = [17 x i8] c"You entered: %d\0A\00"
define i32 @GetThreadsFromUser() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @getchar()
%3 = icmp ne i32 %2, 10
%4 = load i32, i32* @EOF
%5 = icmp ne i32 %2, %4
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %1, label %7
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (...) @getchar()
%10 = add nsw i32 %9, -48
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %10)
ret i32 %10
}