#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*/ isspace(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int get_cmd_input(char *cmd_input) {
  int c;
  int i = 0;
  while (1) {
    c = getchar();
    if (c == EOF || c == '\n')
      return 0;
    if (!isspace(c)) {
      ungetc(c, stdin);
      break;
    }
  }
  while (1) {
    c = getchar();
    if (c == '\n' || c == EOF) {
      cmd_input[i] = 0;
      return 1;
    }
    cmd_input[i] = c;
    if (i == 80 - 1) {
      cmd_input[i] = 0;
      return 1;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<get_cmd_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%eax
je     1169 <get_cmd_input+0x39>
cmpl   $0xa,-0x14(%rbp)
jne    1175 <get_cmd_input+0x45>
movl   $0x0,-0x4(%rbp)
jmp    1224 <get_cmd_input+0xf4>
mov    -0x14(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    119c <get_cmd_input+0x6c>
mov    -0x14(%rbp),%edi
mov    0x2e58(%rip),%rax
mov    (%rax),%esi
call   1050 <ungetc@plt>
jmp    11a1 <get_cmd_input+0x71>
jmp    1143 <get_cmd_input+0x13>
jmp    11a6 <get_cmd_input+0x76>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
je     11cc <get_cmd_input+0x9c>
mov    -0x14(%rbp),%eax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
jne    11e4 <get_cmd_input+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    1224 <get_cmd_input+0xf4>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x4f,-0x18(%rbp)
jne    1216 <get_cmd_input+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    1224 <get_cmd_input+0xf4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a6 <get_cmd_input+0x76>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cmd_input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e9f(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11d0 <get_cmd_input+0xa0>
mov    %eax,%ebp
cmp    (%r15),%eax
je     11d0 <get_cmd_input+0xa0>
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1150 <get_cmd_input+0x20>
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1050 <ungetc@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11c6 <get_cmd_input+0x96>
cmp    (%r15),%eax
je     11c6 <get_cmd_input+0x96>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%r14,%rbx,1)
cmp    $0x4f,%rbx
je     11c1 <get_cmd_input+0x91>
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11c6 <get_cmd_input+0x96>
cmp    (%r15),%eax
jne    11a0 <get_cmd_input+0x70>
jmp    11c6 <get_cmd_input+0x96>
mov    $0x4f,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
define i32 @get_cmd_input(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
br label %6
6: ; preds = %1, %23
%7 = call i32 (...) @getchar()
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %11, %6
store i32 0, i32* %2
br label %55
15: ; preds = %11
%16 = load i32, i32* %4
%17 = call i32 @isspace(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32, i32* @stdin
%22 = call i32 @ungetc(i32 %20, i32 %21)
br label %24
23: ; preds = %15
br label %6
24: ; preds = %19
br label %25
25: ; preds = %24, %52
%26 = call i32 (...) @getchar()
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 10
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %4
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29, %25
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
store i32 1, i32* %2
br label %55
38: ; preds = %29
%39 = load i32, i32* %4
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %3
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 79
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
store i32 1, i32* %2
br label %55
52: ; preds = %38
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %25
55: ; preds = %47, %33, %14
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
define i32 @get_cmd_input(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %8, %1
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
%6 = icmp eq i32 %3, 10
%7 = or i1 %6, %5
br i1 %7, label %37, label %8
8: ; preds = %2
%9 = tail call i32 @isspace(i32 %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %2
11: ; preds = %8
%12 = load i32, i32* @stdin
%13 = tail call i32 @ungetc(i32 %3, i32 %12)
%14 = tail call i32 (...) @getchar()
%15 = icmp eq i32 %14, 10
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %14, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %34, label %21
19: ; preds = %27
%20 = and i64 %28, 4294967295
br label %34
21: ; preds = %11, %27
%22 = phi i64 [ %28, %27 ], [ 0, %11 ]
%23 = phi i32 [ %29, %27 ], [ %14, %11 ]
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds i8, i8* %0, i64 %22
store i8 %24, i8* %25
%26 = icmp eq i64 %22, 79
br i1 %26, label %34, label %27
27: ; preds = %21
%28 = add nuw nsw i64 %22, 1
%29 = tail call i32 (...) @getchar()
%30 = icmp eq i32 %29, 10
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %29, %31
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %19, label %21
34: ; preds = %21, %11, %19
%35 = phi i64 [ 0, %11 ], [ %20, %19 ], [ 79, %21 ]
%36 = getelementptr inbounds i8, i8* %0, i64 %35
store i8 0, i8* %36
br label %37
37: ; preds = %2, %34
%38 = phi i32 [ 1, %34 ], [ 0, %2 ]
ret i32 %38
}