#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*/ Flush_Input();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
void GetInput_With_Fgets() {
  char firstname[5];
  char lastname[5];
  printf("Enter your first name:");
  fgets(firstname, 5, stdin);
  Flush_Input();
  printf("Enter your last name:");
  fgets(lastname, 5, stdin);
  Flush_Input();
  printf("Hello, %s, %s\n", firstname, lastname);
}


x86 assembly (clang, -O0):
<GetInput_With_Fgets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x5(%rbp),%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1050 <fgets@plt>
mov    $0x0,%al
call   1030 <Flush_Input@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa(%rbp),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1050 <fgets@plt>
mov    $0x0,%al
call   1030 <Flush_Input@plt>
lea    -0x5(%rbp),%rsi
lea    -0xa(%rbp),%rdx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetInput_With_Fgets>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%edx
lea    0x13(%rsp),%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <fgets@plt>
xor    %eax,%eax
call   1030 <Flush_Input@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edx
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <fgets@plt>
xor    %eax,%eax
call   1030 <Flush_Input@plt>
lea    0xe96(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter your first name:\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"Enter your last name:\00"
@.str.2 = [15 x i8] c"Hello, %s, %s\0A\00"
define void @GetInput_With_Fgets() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 5, i32 %5)
%7 = call i32 (...) @Flush_Input()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 5, i32 %10)
%12 = call i32 (...) @Flush_Input()
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter your first name:\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"Enter your last name:\00"
@.str.2 = [15 x i8] c"Hello, %s, %s\0A\00"
define void @GetInput_With_Fgets() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 5, i32 %6)
%8 = call i32 (...) @Flush_Input()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %4, i32 5, i32 %10)
%12 = call i32 (...) @Flush_Input()
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* %4)
ret void
}