#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, int /*<<< orphan*/);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strtok(char *, char *);
char *get_input(void) {
  char raw[40];
  char *input;
  printf("> ");
  if (fgets(raw, 40, stdin) == NULL) {
    ;
    printf("error: invalid syntax, see help"
           "\n");
    return NULL;
  } else {
    strtok(raw, "\n");
    ;
  }
  input = malloc(strlen(raw));
  if (input == NULL) {
    ;
    return NULL;
  } else {
    ;
    strcpy(input, raw);
  }
  return input;
}


x86 assembly (clang, -O0):
<get_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11ae <get_input+0x4e>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ff <get_input+0x9f>
lea    -0x30(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1080 <strtok@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ea <get_input+0x8a>
movq   $0x0,-0x8(%rbp)
jmp    11ff <get_input+0x9f>
mov    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input>:
push   %rbx
sub    $0x30,%rsp
lea    0xe84(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x28,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11d2 <get_input+0x62>
lea    0xe60(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1090 <strtok@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     11de <get_input+0x6e>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
jmp    11e0 <get_input+0x70>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [33 x i8] c"error: invalid syntax, see help\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @get_input() {
%1 = alloca i8*
%2 = alloca [40 x i8]
%3 = alloca i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32* @fgets(i8* %5, i32 40, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %1
br label %27
11: ; preds = %0
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%13 = call i32 @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %11
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i8* @malloc(i32 %16)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %14
store i8* null, i8** %1
br label %27
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%24 = call i32 @strcpy(i8* %22, i8* %23)
br label %25
25: ; preds = %21
%26 = load i8*, i8** %3
store i8* %26, i8** %1
br label %27
27: ; preds = %25, %20, %9
%28 = load i8*, i8** %1
ret i8* %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@str = [32 x i8] c"error: invalid syntax, see help\00"
define i8* @get_input() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %2, i32 40, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %16
9: ; preds = %0
%10 = call i32 @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @strlen(i8* %2)
%12 = call i8* @malloc(i32 %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @strcpy(i8* %12, i8* %2)
br label %16
16: ; preds = %9, %14, %7
%17 = phi i8* [ null, %7 ], [ %12, %14 ], [ null, %9 ]
ret i8* %17
}