#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*/ __fpurge(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
void readString3(char variable[], int stringLength, char headerMessage[]) {
  printf("%s", headerMessage);
  fgets(variable, stringLength, stdin);
  variable[strcspn(variable, "\n")] = '\0';
  __fpurge(stdin);
}


x86 assembly (clang, -O0):
<readString3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcspn@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1030 <__fpurge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readString3>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeb0(%rip),%rdi
mov    %rdx,%rsi
call   1040 <printf@plt>
mov    0x2e89(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <fgets@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    (%r14),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <__fpurge@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @readString3(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %9, i32 %10, i32 %11)
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i64 @strcspn(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 0, i8* %16
%17 = load i32, i32* @stdin
%18 = call i32 @__fpurge(i32 %17)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @readString3(i8* %0, i32 %1, i8* %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = load i32, i32* @stdin
%6 = tail call i32 @fgets(i8* %0, i32 %1, i32 %5)
%7 = tail call i64 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 0, i8* %8
%9 = load i32, i32* @stdin
%10 = tail call i32 @__fpurge(i32 %9)
ret void
}