#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ asprintf(char **, char *, char const *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int process_output(int /*<<< orphan*/ *);
int run_chomp(const char *fname) {
  FILE *homchain;
  char *cmd;
  int result;
  assert(asprintf(&cmd, "homchain -d %s", fname) > 0);
  homchain = popen(cmd, "r");
  result = process_output(homchain);
  pclose(homchain);
  free(cmd);
  return result;
}


x86 assembly (clang, -O0):
<run_chomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1060 <asprintf@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <process_output@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_chomp>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rdx
lea    0xe93(%rip),%rsi
mov    %rsp,%rdi
call   1060 <asprintf@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1050 <assert@plt>
mov    (%rsp),%rdi
lea    0xe81(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <process_output@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"homchain -d %s\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @run_chomp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @asprintf(i8** %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp sgt i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %4
%12 = call i32* @popen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = call i32 @process_output(i32* %13)
store i32 %14, i32* %5
%15 = load i32*, i32** %3
%16 = call i32 @pclose(i32* %15)
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* %5
ret i32 %19
}

LLVM IR (-O2):
@.str = [15 x i8] c"homchain -d %s\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @run_chomp(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @asprintf(i8** %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i8*, i8** %2
%9 = call i32* @popen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @process_output(i32* %9)
%11 = call i32 @pclose(i32* %9)
%12 = load i8*, i8** %2
%13 = call i32 @free(i8* %12)
ret i32 %10
}