#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 */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int call_crash_cmd(char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ yyerror(char *);
char *call_func(const char *input) {
  FILE *fpr;
  char *p;
  long len;
  int ret;
  ;
  ret = call_crash_cmd(input);
  if (ret < 0)
    return NULL;
  fpr = fopen("/tmp/.crash_batch", "r");
  if (fpr == NULL) {
    yyerror("call_func, fopen failed\n");
    return NULL;
  }
  ret = fseek(fpr, 0, SEEK_END);
  if (ret != 0) {
    yyerror("call_func, SEEK_END failed\n");
    fclose(fpr);
    return NULL;
  }
  len = ftell(fpr);
  if (len < 0) {
    yyerror("call_func, ftell failed\n");
    fclose(fpr);
    return NULL;
  }
  ret = fseek(fpr, 0, SEEK_SET);
  if (ret != 0) {
    yyerror("call_func, SEEK_SET failed\n");
    fclose(fpr);
    return NULL;
  }
  p = malloc(len + 1);
  if (p == NULL) {
    yyerror("call_func, malloc failed\n");
    fclose(fpr);
    return NULL;
  }
  ret = fread(p, len, 1, fpr);
  if (ret <= 0) {
    yyerror("call_func, fread failed\n");
    fclose(fpr);
    free(p);
    return NULL;
  }
  p[len] = '\0';
  fclose(fpr);
  return p;
}


x86 assembly (clang, -O0):
<call_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <call_crash_cmd@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11bf <call_func+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
lea    0xe3a(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fa <call_func+0x6a>
lea    0xe2c(%rip),%rdi
call   1060 <yyerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x18(%rbp),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     123d <call_func+0xad>
lea    0xe0b(%rip),%rdi
call   1060 <yyerror@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1277 <call_func+0xe7>
lea    0xded(%rip),%rdi
call   1060 <yyerror@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x18(%rbp),%rdi
mov    0x2d56(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12ba <call_func+0x12a>
lea    0xdc3(%rip),%rdi
call   1060 <yyerror@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12f8 <call_func+0x168>
lea    0xda1(%rip),%rdi
call   1060 <yyerror@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1050 <fread@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jg     1346 <call_func+0x1b6>
lea    0xd76(%rip),%rdi
call   1060 <yyerror@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1363 <call_func+0x1d3>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_func>:
push   %r15
push   %r14
push   %rbx
call   1040 <call_crash_cmd@plt>
test   %eax,%eax
js     11f2 <call_func+0x62>
lea    0xe5b(%rip),%rdi
lea    0xe66(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     11e6 <call_func+0x56>
mov    %rax,%r14
mov    0x2e28(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %eax,%eax
je     11fd <call_func+0x6d>
lea    0xe56(%rip),%rdi
call   1060 <yyerror@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
jmp    11f2 <call_func+0x62>
lea    0xe27(%rip),%rdi
call   1060 <yyerror@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
call   1080 <ftell@plt>
test   %rax,%rax
js     122d <call_func+0x9d>
mov    %rax,%r15
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %eax,%eax
je     1236 <call_func+0xa6>
lea    0xe37(%rip),%rdi
jmp    11d7 <call_func+0x47>
lea    0xe15(%rip),%rdi
jmp    11d7 <call_func+0x47>
lea    0x1(%r15),%rdi
call   1090 <malloc@plt>
test   %rax,%rax
je     126d <call_func+0xdd>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
test   %eax,%eax
jle    1279 <call_func+0xe9>
movb   $0x0,(%rbx,%r15,1)
mov    %r14,%rdi
call   1070 <fclose@plt>
jmp    11f4 <call_func+0x64>
lea    0xe0a(%rip),%rdi
jmp    11d7 <call_func+0x47>
lea    0xe18(%rip),%rdi
call   1060 <yyerror@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11f2 <call_func+0x62>

LLVM IR (-O0):
@.str = [18 x i8] c"/tmp/.crash_batch\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"call_func, fopen failed\0A\00"
@SEEK_END = global i32 0
@.str.3 = [28 x i8] c"call_func, SEEK_END failed\0A\00"
@.str.4 = [25 x i8] c"call_func, ftell failed\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [28 x i8] c"call_func, SEEK_SET failed\0A\00"
@.str.6 = [26 x i8] c"call_func, malloc failed\0A\00"
@.str.7 = [25 x i8] c"call_func, fread failed\0A\00"
define i8* @call_func(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @call_crash_cmd(i8* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i8* null, i8** %2
br label %78
13: ; preds = %1
%14 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %4
%15 = load i32*, i32** %4
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %78
19: ; preds = %13
%20 = load i32*, i32** %4
%21 = load i32, i32* @SEEK_END
%22 = call i32 @fseek(i32* %20, i32 0, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = call i32 @yyerror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
store i8* null, i8** %2
br label %78
29: ; preds = %19
%30 = load i32*, i32** %4
%31 = call i64 @ftell(i32* %30)
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32*, i32** %4
%37 = call i32 @fclose(i32* %36)
store i8* null, i8** %2
br label %78
38: ; preds = %29
%39 = load i32*, i32** %4
%40 = load i32, i32* @SEEK_SET
%41 = call i32 @fseek(i32* %39, i32 0, i32 %40)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %38
%45 = call i32 @yyerror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32*, i32** %4
%47 = call i32 @fclose(i32* %46)
store i8* null, i8** %2
br label %78
48: ; preds = %38
%49 = load i64, i64* %6
%50 = add nsw i64 %49, 1
%51 = call i8* @malloc(i64 %50)
store i8* %51, i8** %5
%52 = load i8*, i8** %5
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %58
54: ; preds = %48
%55 = call i32 @yyerror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%56 = load i32*, i32** %4
%57 = call i32 @fclose(i32* %56)
store i8* null, i8** %2
br label %78
58: ; preds = %48
%59 = load i8*, i8** %5
%60 = load i64, i64* %6
%61 = load i32*, i32** %4
%62 = call i32 @fread(i8* %59, i64 %60, i32 1, i32* %61)
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = icmp sle i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %58
%66 = call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%67 = load i32*, i32** %4
%68 = call i32 @fclose(i32* %67)
%69 = load i8*, i8** %5
%70 = call i32 @free(i8* %69)
store i8* null, i8** %2
br label %78
71: ; preds = %58
%72 = load i8*, i8** %5
%73 = load i64, i64* %6
%74 = getelementptr inbounds i8, i8* %72, i64 %73
store i8 0, i8* %74
%75 = load i32*, i32** %4
%76 = call i32 @fclose(i32* %75)
%77 = load i8*, i8** %5
store i8* %77, i8** %2
br label %78
78: ; preds = %71, %65, %54, %44, %34, %25, %17, %12
%79 = load i8*, i8** %2
ret i8* %79
}

LLVM IR (-O2):
@.str = [18 x i8] c"/tmp/.crash_batch\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"call_func, fopen failed\0A\00"
@SEEK_END = global i32 0
@.str.3 = [28 x i8] c"call_func, SEEK_END failed\0A\00"
@.str.4 = [25 x i8] c"call_func, ftell failed\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [28 x i8] c"call_func, SEEK_SET failed\0A\00"
@.str.6 = [26 x i8] c"call_func, malloc failed\0A\00"
@.str.7 = [25 x i8] c"call_func, fread failed\0A\00"
define noalias i8* @call_func(i8* %0) {
%2 = tail call i32 @call_crash_cmd(i8* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %46, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %46
9: ; preds = %4
%10 = load i32, i32* @SEEK_END
%11 = tail call i32 @fseek(i32* %5, i32 0, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call i32 @yyerror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @fclose(i32* %5)
br label %46
16: ; preds = %9
%17 = tail call i64 @ftell(i32* %5)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @fclose(i32* %5)
br label %46
22: ; preds = %16
%23 = load i32, i32* @SEEK_SET
%24 = tail call i32 @fseek(i32* %5, i32 0, i32 %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = tail call i32 @yyerror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%28 = tail call i32 @fclose(i32* %5)
br label %46
29: ; preds = %22
%30 = add nuw nsw i64 %17, 1
%31 = tail call i8* @malloc(i64 %30)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = tail call i32 @yyerror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%35 = tail call i32 @fclose(i32* %5)
br label %46
36: ; preds = %29
%37 = tail call i32 @fread(i8* %31, i64 %17, i32 1, i32* %5)
%38 = icmp slt i32 %37, 1
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = tail call i32 @yyerror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%41 = tail call i32 @fclose(i32* %5)
%42 = tail call i32 @free(i8* %31)
br label %46
43: ; preds = %36
%44 = getelementptr inbounds i8, i8* %31, i64 %17
store i8 0, i8* %44
%45 = tail call i32 @fclose(i32* %5)
br label %46
46: ; preds = %1, %43, %39, %33, %26, %19, %13, %7
%47 = phi i8* [ null, %7 ], [ null, %13 ], [ null, %19 ], [ null, %26 ], [ null, %33 ], [ null, %39 ], [ %31, %43 ], [ null, %1 ]
ret i8* %47
}