#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int is_valid_input(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char *strtrim(char *);
void test_parser(char *buf) {
  char *str;
  int ret;
  while (fgets(buf, 4096, stdin)) {
    str = strtrim(buf);
    ret = is_valid_input(str);
    if (ret)
      printf("input is valid\n");
    else
      printf("input is invalid\n");
  }
}


x86 assembly (clang, -O0):
<test_parser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11b2 <test_parser+0x72>
mov    -0x8(%rbp),%rdi
call   1050 <strtrim@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <is_valid_input@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a1 <test_parser+0x61>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <test_parser+0x6d>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
jmp    114c <test_parser+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_parser>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e96(%rip),%r14
mov    (%r14),%edx
mov    $0x1000,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11b3 <test_parser+0x73>
lea    0xe95(%rip),%r15
lea    0xe9f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <strtrim@plt>
mov    %rax,%rdi
call   1060 <is_valid_input@plt>
test   %eax,%eax
mov    %r12,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    1180 <test_parser+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [16 x i8] c"input is valid\0A\00"
@.str.1 = [18 x i8] c"input is invalid\0A\00"
define void @test_parser(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
br label %5
5: ; preds = %21, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 4096, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = call i8* @strtrim(i8* %11)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @is_valid_input(i8* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %10
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %5
22: ; preds = %5
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [17 x i8] c"input is invalid\00"
@str.2 = [15 x i8] c"input is valid\00"
define void @test_parser(i8* %0) {
%2 = load i32, i32* @stdin
%3 = tail call i64 @fgets(i8* %0, i32 4096, i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = tail call i8* @strtrim(i8* %0)
%7 = tail call i32 @is_valid_input(i8* %6)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.2, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = load i32, i32* @stdin
%12 = tail call i64 @fgets(i8* %0, i32 4096, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %1
ret void
}