#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 LOG_ERR;
int LOG_USER;
int PATH_MAX;
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ get_core_name(char *, char *, char *);
int limit_core_files(char *, int);
int parse_options(int, char **, int *, char **, char **, char **);
int send_mail(char *, char *, char *, char *);
int /*<<< orphan*/ stdin;
char *strerror(int);
int /*<<< orphan*/ syslog(int, char *, ...);
int main(int argc, char **argv) {
  int max_cores, deleted, ret, done = 0;
  char *exe_name, *core_dir, *email;
  char core_name[PATH_MAX];
  FILE *fp;
  ret = parse_options(argc, argv, &max_cores, &exe_name, &core_dir, &email);
  if (ret) {
    syslog(LOG_USER | LOG_ERR, "parse_options error\n");
    return 1;
  }
  get_core_name(core_dir, exe_name, core_name);
  fp = fopen(core_name, "w");
  if (!fp) {
    int err = errno;
    syslog(LOG_USER | LOG_ERR,
           "unable to open %s: "
           "error %d (%s)\n",
           core_name, err, strerror(err));
    return err;
  }
  do {
    size_t res;
    char buf[1024];
    size_t nread = fread(buf, 1, 1024, stdin);
    if (nread != 1024) {
      if (ferror(fp)) {
        int err = errno;
        syslog(LOG_USER | LOG_ERR,
               "error reading core "
               "file from stdin: %d (%s)",
               err, strerror(err));
        fclose(fp);
        return err;
      } else {
        done = 1;
      }
    }
    res = fwrite(buf, 1, nread, fp);
    if (res != nread) {
      int err = errno;
      syslog(LOG_USER | LOG_ERR,
             "error writing core "
             "file to %s: %d (%s)",
             core_name, err, strerror(err));
      fclose(fp);
      return err;
    }
  } while (!done);
  fclose(fp);
  deleted = limit_core_files(core_dir, max_cores);
  if (deleted < 0) {
    syslog(LOG_USER | LOG_ERR,
           "error limiting number of core "
           "files: %d",
           deleted);
  }
  ret = send_mail(exe_name, core_dir, core_name, email);
  if (ret) {
    syslog(LOG_USER | LOG_ERR,
           "send_mail failed with error "
           "code %d\n",
           ret);
  }
  syslog(LOG_USER | LOG_ERR, "wrote core %s. Deleted %d extra core%s\n",
         core_name, deleted, ((deleted == 1) ? "" : "s"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x478(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
call   1060 <parse_options@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     125b <main+0xab>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
mov    0x2d80(%rip),%rax
or     (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1574 <main+0x3c4>
mov    -0x478(%rbp),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <get_core_name@plt>
mov    -0x478(%rbp),%rdi
lea    0xd98(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12fc <main+0x14c>
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    0x2d0b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x480(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x47c(%rbp)
mov    -0x58(%rbp),%edi
call   10c0 <strerror@plt>
mov    -0x480(%rbp),%edi
mov    -0x478(%rbp),%rdx
mov    -0x47c(%rbp),%ecx
mov    %rax,%r8
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1574 <main+0x3c4>
jmp    1301 <main+0x151>
lea    -0x460(%rbp),%rdi
mov    0x2cc9(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %rax,-0x468(%rbp)
cmpq   $0x400,-0x468(%rbp)
je     13d0 <main+0x220>
mov    -0x50(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     13c4 <main+0x214>
mov    0x2c76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x46c(%rbp)
mov    0x2c7f(%rip),%rax
mov    (%rax),%eax
mov    0x2c4e(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x488(%rbp)
mov    -0x46c(%rbp),%eax
mov    %eax,-0x484(%rbp)
mov    -0x46c(%rbp),%edi
call   10c0 <strerror@plt>
mov    -0x488(%rbp),%edi
mov    -0x484(%rbp),%edx
mov    %rax,%rcx
lea    0xc9a(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x50(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x46c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1574 <main+0x3c4>
movl   $0x1,-0x20(%rbp)
jmp    13d0 <main+0x220>
lea    -0x460(%rbp),%rdi
mov    -0x468(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0x468(%rbp),%rax
je     1481 <main+0x2d1>
mov    0x2bc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x470(%rbp)
mov    0x2bc9(%rip),%rax
mov    (%rax),%eax
mov    0x2b98(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x490(%rbp)
mov    -0x470(%rbp),%eax
mov    %eax,-0x48c(%rbp)
mov    -0x470(%rbp),%edi
call   10c0 <strerror@plt>
mov    -0x490(%rbp),%edi
mov    -0x478(%rbp),%rdx
mov    -0x48c(%rbp),%ecx
mov    %rax,%r8
lea    0xc09(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x50(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x470(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    1574 <main+0x3c4>
jmp    1486 <main+0x2d6>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1301 <main+0x151>
mov    -0x50(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10d0 <limit_core_files@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    14dc <main+0x32c>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
mov    0x2aef(%rip),%rax
or     (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xbb7(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x478(%rbp),%rdx
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
call   1050 <send_mail@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1524 <main+0x374>
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
mov    0x2aa7(%rip),%rax
or     (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xb97(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
mov    -0x478(%rbp),%rdx
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
mov    0x2a7d(%rip),%rax
or     (%rax),%edi
mov    -0x18(%rbp),%ecx
mov    -0x18(%rbp),%esi
lea    0xbb7(%rip),%r8
lea    0xae7(%rip),%rax
cmp    $0x1,%esi
cmove  %rax,%r8
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1090 <syslog@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsp,%r12
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x3c(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x50(%rbp),%r9
call   1060 <parse_options@plt>
test   %eax,%eax
je     1224 <main+0x74>
mov    0x2ddf(%rip),%rax
mov    0x2db0(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xded(%rip),%rsi
xor    %eax,%eax
call   1090 <syslog@plt>
mov    $0x1,%ebx
jmp    1484 <main+0x2d4>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %r15,%rdx
call   1080 <get_core_name@plt>
lea    0xdda(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1321 <main+0x171>
mov    %rax,%r14
mov    %r12,-0x30(%rbp)
mov    0x2d7e(%rip),%r13
mov    0x0(%r13),%ecx
lea    -0x450(%rbp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %rax,%rbx
cmp    $0x400,%rax
jne    12cd <main+0x11d>
lea    -0x450(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
cmp    %rbx,%rax
jne    143b <main+0x28b>
mov    0x0(%r13),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %rax,%rbx
cmp    $0x400,%rax
je     1290 <main+0xe0>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
mov    -0x30(%rbp),%r12
je     1363 <main+0x1b3>
mov    0x2cdf(%rip),%rax
mov    (%rax),%ebx
mov    0x2cee(%rip),%rax
mov    0x2cbf(%rip),%rcx
mov    (%rcx),%r15d
or     (%rax),%r15d
mov    %ebx,%edi
call   10c0 <strerror@plt>
lea    0xd2c(%rip),%rsi
mov    %r15d,%edi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <syslog@plt>
jmp    147c <main+0x2cc>
mov    0x2ca0(%rip),%rax
mov    (%rax),%ebx
mov    0x2caf(%rip),%rax
mov    0x2c80(%rip),%rcx
mov    (%rcx),%r14d
or     (%rax),%r14d
mov    %ebx,%edi
call   10c0 <strerror@plt>
lea    0xccb(%rip),%rsi
mov    %r14d,%edi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1090 <syslog@plt>
jmp    1484 <main+0x2d4>
lea    -0x450(%rbp),%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
cmp    %rbx,%rax
jne    143b <main+0x28b>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   10d0 <limit_core_files@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    13c1 <main+0x211>
mov    0x2c3b(%rip),%rax
mov    0x2c0c(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xcd5(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <syslog@plt>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x50(%rbp),%rcx
mov    %r15,%rdx
call   1050 <send_mail@plt>
test   %eax,%eax
mov    -0x30(%rbp),%r12
je     13ff <main+0x24f>
mov    0x2bfc(%rip),%rcx
mov    0x2bcd(%rip),%rdx
mov    (%rdx),%edi
or     (%rcx),%edi
lea    0xcbe(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <syslog@plt>
mov    0x2bda(%rip),%rax
mov    0x2bab(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
cmp    $0x1,%r14d
lea    0xc1c(%rip),%rax
lea    0xcde(%rip),%r8
cmove  %rax,%r8
lea    0xcab(%rip),%rsi
xor    %ebx,%ebx
mov    %r15,%rdx
mov    %r14d,%ecx
jmp    1357 <main+0x1a7>
mov    0x2b86(%rip),%rax
mov    (%rax),%ebx
mov    0x2b95(%rip),%rax
mov    0x2b66(%rip),%rcx
mov    (%rcx),%r12d
or     (%rax),%r12d
mov    %ebx,%edi
call   10c0 <strerror@plt>
lea    0xbff(%rip),%rsi
mov    %r12d,%edi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1090 <syslog@plt>
mov    -0x30(%rbp),%r12
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    %r12,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@LOG_USER = global i32 0
@LOG_ERR = global i32 0
@.str = [21 x i8] c"parse_options error\0A\00"
@.str.1 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.2 = [34 x i8] c"unable to open %s: error %d (%s)\0A\00"
@stdin = global i32 0
@.str.3 = [44 x i8] c"error reading core file from stdin: %d (%s)\00"
@.str.4 = [39 x i8] c"error writing core file to %s: %d (%s)\00"
@.str.5 = [40 x i8] c"error limiting number of core files: %d\00"
@.str.6 = [37 x i8] c"send_mail failed with error code %d\0A\00"
@.str.7 = [40 x i8] c"wrote core %s. Deleted %d extra core%s\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [2 x i8] c"s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i64
%19 = alloca [1024 x i8]
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%23 = load i32, i32* @PATH_MAX
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %13
%26 = alloca i8, i64 %24
store i64 %24, i64* %14
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call i32 @parse_options(i32 %27, i8** %28, i32* %6, i8** %10, i8** %11, i8** %12)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = load i32, i32* @LOG_USER
%34 = load i32, i32* @LOG_ERR
%35 = or i32 %33, %34
%36 = call i32 (i32, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %16
br label %141
37: ; preds = %2
%38 = load i8*, i8** %11
%39 = load i8*, i8** %10
%40 = call i32 @get_core_name(i8* %38, i8* %39, i8* %26)
%41 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %15
%42 = load i32*, i32** %15
%43 = icmp ne i32* %42, null
br i1 %43, label %54, label %44
44: ; preds = %37
%45 = load i32, i32* @errno
store i32 %45, i32* %17
%46 = load i32, i32* @LOG_USER
%47 = load i32, i32* @LOG_ERR
%48 = or i32 %46, %47
%49 = load i32, i32* %17
%50 = load i32, i32* %17
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, ...) @syslog(i32 %48, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %26, i32 %49, i8* %51)
%53 = load i32, i32* %17
store i32 %53, i32* %3
store i32 1, i32* %16
br label %141
54: ; preds = %37
br label %55
55: ; preds = %100, %54
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%57 = load i32, i32* @stdin
%58 = call i64 @fread(i8* %56, i32 1, i32 1024, i32 %57)
store i64 %58, i64* %20
%59 = load i64, i64* %20
%60 = icmp ne i64 %59, 1024
br i1 %60, label %61, label %79
61: ; preds = %55
%62 = load i32*, i32** %15
%63 = call i64 @ferror(i32* %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %77
65: ; preds = %61
%66 = load i32, i32* @errno
store i32 %66, i32* %21
%67 = load i32, i32* @LOG_USER
%68 = load i32, i32* @LOG_ERR
%69 = or i32 %67, %68
%70 = load i32, i32* %21
%71 = load i32, i32* %21
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i32, i8*, ...) @syslog(i32 %69, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %70, i8* %72)
%74 = load i32*, i32** %15
%75 = call i32 @fclose(i32* %74)
%76 = load i32, i32* %21
store i32 %76, i32* %3
store i32 1, i32* %16
br label %141
77: ; preds = %61
store i32 1, i32* %9
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78, %55
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%81 = load i64, i64* %20
%82 = load i32*, i32** %15
%83 = call i64 @fwrite(i8* %80, i32 1, i64 %81, i32* %82)
store i64 %83, i64* %18
%84 = load i64, i64* %18
%85 = load i64, i64* %20
%86 = icmp ne i64 %84, %85
br i1 %86, label %87, label %99
87: ; preds = %79
%88 = load i32, i32* @errno
store i32 %88, i32* %22
%89 = load i32, i32* @LOG_USER
%90 = load i32, i32* @LOG_ERR
%91 = or i32 %89, %90
%92 = load i32, i32* %22
%93 = load i32, i32* %22
%94 = call i8* @strerror(i32 %93)
%95 = call i32 (i32, i8*, ...) @syslog(i32 %91, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %26, i32 %92, i8* %94)
%96 = load i32*, i32** %15
%97 = call i32 @fclose(i32* %96)
%98 = load i32, i32* %22
store i32 %98, i32* %3
store i32 1, i32* %16
br label %141
99: ; preds = %79
br label %100
100: ; preds = %99
%101 = load i32, i32* %9
%102 = icmp ne i32 %101, 0
%103 = xor i1 %102, true
br i1 %103, label %55, label %104
104: ; preds = %100
%105 = load i32*, i32** %15
%106 = call i32 @fclose(i32* %105)
%107 = load i8*, i8** %11
%108 = load i32, i32* %6
%109 = call i32 @limit_core_files(i8* %107, i32 %108)
store i32 %109, i32* %7
%110 = load i32, i32* %7
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %118
112: ; preds = %104
%113 = load i32, i32* @LOG_USER
%114 = load i32, i32* @LOG_ERR
%115 = or i32 %113, %114
%116 = load i32, i32* %7
%117 = call i32 (i32, i8*, ...) @syslog(i32 %115, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %112, %104
%119 = load i8*, i8** %10
%120 = load i8*, i8** %11
%121 = load i8*, i8** %12
%122 = call i32 @send_mail(i8* %119, i8* %120, i8* %26, i8* %121)
store i32 %122, i32* %8
%123 = load i32, i32* %8
%124 = icmp ne i32 %123, 0
br i1 %124, label %125, label %131
125: ; preds = %118
%126 = load i32, i32* @LOG_USER
%127 = load i32, i32* @LOG_ERR
%128 = or i32 %126, %127
%129 = load i32, i32* %8
%130 = call i32 (i32, i8*, ...) @syslog(i32 %128, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %125, %118
%132 = load i32, i32* @LOG_USER
%133 = load i32, i32* @LOG_ERR
%134 = or i32 %132, %133
%135 = load i32, i32* %7
%136 = load i32, i32* %7
%137 = icmp eq i32 %136, 1
%138 = zext i1 %137 to i64
%139 = select i1 %137, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%140 = call i32 (i32, i8*, ...) @syslog(i32 %134, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %26, i32 %135, i8* %139)
store i32 0, i32* %3
store i32 1, i32* %16
br label %141
141: ; preds = %131, %87, %65, %44, %32
%142 = load i8*, i8** %13
%143 = load i32, i32* %3
ret i32 %143
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@LOG_USER = global i32 0
@LOG_ERR = global i32 0
@.str = [21 x i8] c"parse_options error\0A\00"
@.str.1 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.2 = [34 x i8] c"unable to open %s: error %d (%s)\0A\00"
@stdin = global i32 0
@.str.3 = [44 x i8] c"error reading core file from stdin: %d (%s)\00"
@.str.4 = [39 x i8] c"error writing core file to %s: %d (%s)\00"
@.str.5 = [40 x i8] c"error limiting number of core files: %d\00"
@.str.6 = [37 x i8] c"send_mail failed with error code %d\0A\00"
@.str.7 = [40 x i8] c"wrote core %s. Deleted %d extra core%s\0A\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [2 x i8] c"s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast i8** %4 to i8*
%10 = bitcast i8** %5 to i8*
%11 = bitcast i8** %6 to i8*
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = tail call i8* @llvm.stacksave()
%15 = alloca i8, i64 %13
%16 = call i32 @parse_options(i32 %0, i8** %1, i32* %3, i8** %4, i8** %5, i8** %6)
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %2
%19 = load i32, i32* @LOG_USER
%20 = load i32, i32* @LOG_ERR
%21 = or i32 %20, %19
%22 = call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %102
23: ; preds = %2
%24 = load i8*, i8** %5
%25 = load i8*, i8** %4
%26 = call i32 @get_core_name(i8* %24, i8* %25, i8* %15)
%27 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %34, label %29
29: ; preds = %23
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%31 = load i32, i32* @stdin
%32 = call i64 @fread(i8* %30, i32 1, i32 1024, i32 %31)
%33 = icmp eq i64 %32, 1024
br i1 %33, label %52, label %41
34: ; preds = %23
%35 = load i32, i32* @errno
%36 = load i32, i32* @LOG_USER
%37 = load i32, i32* @LOG_ERR
%38 = or i32 %37, %36
%39 = call i8* @strerror(i32 %35)
%40 = call i32 (i32, i8*, ...) @syslog(i32 %38, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %35, i8* %39)
br label %102
41: ; preds = %69, %29
%42 = phi i64 [ %32, %29 ], [ %71, %69 ]
%43 = call i64 @ferror(i32* %27)
%44 = icmp eq i64 %43, 0
br i1 %44, label %56, label %45
45: ; preds = %41
%46 = load i32, i32* @errno
%47 = load i32, i32* @LOG_USER
%48 = load i32, i32* @LOG_ERR
%49 = or i32 %48, %47
%50 = call i8* @strerror(i32 %46)
%51 = call i32 (i32, i8*, ...) @syslog(i32 %49, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %46, i8* %50)
br label %66
52: ; preds = %29, %69
%53 = phi i64 [ %71, %69 ], [ %32, %29 ]
%54 = call i64 @fwrite(i8* %30, i32 1, i64 %53, i32* %27)
%55 = icmp eq i64 %54, %53
br i1 %55, label %69, label %59
56: ; preds = %41
%57 = call i64 @fwrite(i8* %30, i32 1, i64 %42, i32* %27)
%58 = icmp eq i64 %57, %42
br i1 %58, label %73, label %59
59: ; preds = %52, %56
%60 = load i32, i32* @errno
%61 = load i32, i32* @LOG_USER
%62 = load i32, i32* @LOG_ERR
%63 = or i32 %62, %61
%64 = call i8* @strerror(i32 %60)
%65 = call i32 (i32, i8*, ...) @syslog(i32 %63, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %15, i32 %60, i8* %64)
br label %66
66: ; preds = %59, %45
%67 = phi i32 [ %46, %45 ], [ %60, %59 ]
%68 = call i32 @fclose(i32* %27)
br label %102
69: ; preds = %52
%70 = load i32, i32* @stdin
%71 = call i64 @fread(i8* %30, i32 1, i32 1024, i32 %70)
%72 = icmp eq i64 %71, 1024
br i1 %72, label %52, label %41
73: ; preds = %56
%74 = call i32 @fclose(i32* %27)
%75 = load i8*, i8** %5
%76 = load i32, i32* %3
%77 = call i32 @limit_core_files(i8* %75, i32 %76)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %73
%80 = load i32, i32* @LOG_USER
%81 = load i32, i32* @LOG_ERR
%82 = or i32 %81, %80
%83 = call i32 (i32, i8*, ...) @syslog(i32 %82, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %77)
br label %84
84: ; preds = %79, %73
%85 = load i8*, i8** %4
%86 = load i8*, i8** %5
%87 = load i8*, i8** %6
%88 = call i32 @send_mail(i8* %85, i8* %86, i8* %15, i8* %87)
%89 = icmp eq i32 %88, 0
br i1 %89, label %95, label %90
90: ; preds = %84
%91 = load i32, i32* @LOG_USER
%92 = load i32, i32* @LOG_ERR
%93 = or i32 %92, %91
%94 = call i32 (i32, i8*, ...) @syslog(i32 %93, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %88)
br label %95
95: ; preds = %90, %84
%96 = load i32, i32* @LOG_USER
%97 = load i32, i32* @LOG_ERR
%98 = or i32 %97, %96
%99 = icmp eq i32 %77, 1
%100 = select i1 %99, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%101 = call i32 (i32, i8*, ...) @syslog(i32 %98, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i8* %15, i32 %77, i8* %100)
br label %102
102: ; preds = %66, %95, %34, %18
%103 = phi i32 [ 1, %18 ], [ 0, %95 ], [ %35, %34 ], [ %67, %66 ]
ret i32 %103
}