#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 EXIT_FAILURE;
int EXIT_SUCCESS;
char *argv_to_buf(char **);
char *fp_to_buf(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
char *strlen(char *);
int main(int argc __attribute__((unused)), char **argv) {
  int ret;
  char *abuf, *ibuf;
  abuf = argv_to_buf(argv + 1);
  if (!abuf) {
    ret = EXIT_FAILURE;
    goto done;
  }
  ibuf = fp_to_buf(stdin);
  if (!ibuf) {
    fprintf(stderr, "failed to read stdin\n");
    ret = EXIT_FAILURE;
    goto done_free_abuf;
  }
  if (strcmp(abuf, ibuf)) {
    fprintf(stderr, "error: expected: '%s'\ngot: '%s'\n", abuf, ibuf);
    fprintf(stderr, "len(expected) = %Zd, len(got) = %Zd\n", strlen(abuf),
            strlen(ibuf));
    ret = EXIT_FAILURE;
    goto done_free_ibuf;
  }
  ret = EXIT_SUCCESS;
done_free_ibuf:
  free(ibuf);
done_free_abuf:
  free(abuf);
done:
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1080 <argv_to_buf@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a3 <main+0x43>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1287 <main+0x127>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1040 <fp_to_buf@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e8 <main+0x88>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    127e <main+0x11e>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1269 <main+0x109>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1275 <main+0x115>
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0x8(%rsi),%rdi
call   1080 <argv_to_buf@plt>
test   %rax,%rax
je     11fb <main+0x9b>
mov    %rax,%r14
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1040 <fp_to_buf@plt>
test   %rax,%rax
je     1206 <main+0xa6>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1228 <main+0xc8>
mov    0x2e2b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe5f(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%r15d
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe55(%rip),%rsi
mov    %r15d,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2dd7(%rip),%rax
jmp    122f <main+0xcf>
mov    0x2dce(%rip),%rax
mov    (%rax),%ebp
jmp    1241 <main+0xe1>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%ebp
jmp    1239 <main+0xd9>
mov    0x2d99(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"failed to read stdin\0A\00"
@.str.1 = [33 x i8] c"error: expected: '%s'\0Agot: '%s'\0A\00"
@.str.2 = [37 x i8] c"len(expected) = %Zd, len(got) = %Zd\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = call i8* @argv_to_buf(i8** %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %6
br label %50
16: ; preds = %2
%17 = load i32, i32* @stdin
%18 = call i8* @fp_to_buf(i32 %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %6
br label %47
25: ; preds = %16
%26 = load i8*, i8** %7
%27 = load i8*, i8** %8
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %42
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %7
%37 = call i8* @strlen(i8* %36)
%38 = load i8*, i8** %8
%39 = call i8* @strlen(i8* %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %6
br label %44
42: ; preds = %25
%43 = load i32, i32* @EXIT_SUCCESS
store i32 %43, i32* %6
br label %44
44: ; preds = %42, %30
%45 = load i8*, i8** %8
%46 = call i32 @free(i8* %45)
br label %47
47: ; preds = %44, %21
%48 = load i8*, i8** %7
%49 = call i32 @free(i8* %48)
br label %50
50: ; preds = %47, %14
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"failed to read stdin\0A\00"
@.str.1 = [33 x i8] c"error: expected: '%s'\0Agot: '%s'\0A\00"
@.str.2 = [37 x i8] c"len(expected) = %Zd, len(got) = %Zd\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = tail call i8* @argv_to_buf(i8** %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @EXIT_FAILURE
br label %33
8: ; preds = %2
%9 = load i32, i32* @stdin
%10 = tail call i8* @fp_to_buf(i32 %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
br label %30
16: ; preds = %8
%17 = tail call i64 @strcmp(i8* %4, i8* %10)
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %10)
%22 = load i32, i32* @stderr
%23 = tail call i8* @strlen(i8* %4)
%24 = tail call i8* @strlen(i8* %10)
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24)
br label %26
26: ; preds = %16, %19
%27 = phi i32* [ @EXIT_FAILURE, %19 ], [ @EXIT_SUCCESS, %16 ]
%28 = load i32, i32* %27
%29 = tail call i32 @free(i8* %10)
br label %30
30: ; preds = %26, %12
%31 = phi i32 [ %28, %26 ], [ %15, %12 ]
%32 = tail call i32 @free(i8* %4)
br label %33
33: ; preds = %30, %6
%34 = phi i32 [ %31, %30 ], [ %7, %6 ]
ret i32 %34
}