#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*/ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char getchar();
scalar_t__ malloc(int const);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int const strlen(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
void int_input(int *integer, const int size) {
  char *string = (char *)malloc(size);
  fgets(string, size, stdin);
  string[strcspn(string, "\r\n")] = '\0';
  if (strlen(string) == size - 1) {
    while (getchar() != '\n') {
    }
  }
  *integer = (int)strtol(string, NULL, 0);
  free(string);
  system("cls");
}


x86 assembly (clang, -O0):
<int_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    120c <int_input+0x8c>
jmp    11ef <int_input+0x6f>
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1207 <int_input+0x87>
jmp    11ef <int_input+0x6f>
jmp    120c <int_input+0x8c>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xdd0(%rip),%rdi
call   1050 <system@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_input>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <fgets@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jne    11db <int_input+0x5b>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
jne    11d0 <int_input+0x50>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe0a(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <system@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [4 x i8] c"cls\00"
define void @int_input(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i32, i32* %4
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %9, i32 %10, i32 %11)
%13 = load i8*, i8** %5
%14 = load i8*, i8** %5
%15 = call i64 @strcspn(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 0, i8* %16
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %29
22: ; preds = %2
br label %23
23: ; preds = %27, %22
%24 = call signext i8 (...) @getchar()
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br i1 %26, label %27, label %28
27: ; preds = %23
br label %23
28: ; preds = %23
br label %29
29: ; preds = %28, %2
%30 = load i8*, i8** %5
%31 = call i64 @strtol(i8* %30, i32* null, i32 0)
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %3
store i32 %32, i32* %33
%34 = load i8*, i8** %5
%35 = call i32 @free(i8* %34)
%36 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [4 x i8] c"cls\00"
define void @int_input(i32* nocapture writeonly %0, i32 %1) {
%3 = tail call i64 @malloc(i32 %1)
%4 = inttoptr i64 %3 to i8*
%5 = load i32, i32* @stdin
%6 = tail call i32 @fgets(i8* %4, i32 %1, i32 %5)
%7 = tail call i64 @strcspn(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8 0, i8* %8
%9 = tail call i32 @strlen(i8* %4)
%10 = add nsw i32 %1, -1
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %2, %12
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12, %2
%16 = tail call i64 @strtol(i8* nocapture %4, i32* null, i32 0)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %0
%18 = tail call i32 @free(i8* %4)
%19 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret void
}