#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 scalar_t__ uid_t;
struct passwd {
  scalar_t__ pw_uid;
  char *pw_name;
};

/* Variables and functions */
int EX_OK;
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ LOG_MAIL;
int /*<<< orphan*/ LOG_PERROR;
int deliver(int, char *, int);
int /*<<< orphan*/ exit(int);
char *getlogin();
int getopt(int, char **, char *);
struct passwd *getpwnam(char const *);
struct passwd *getpwuid(scalar_t__);
scalar_t__ getuid();
int /*<<< orphan*/ logerr(int /*<<< orphan*/, char *);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
char *optarg;
scalar_t__ optind;
int store(char const *);
int /*<<< orphan*/ umask(int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  struct passwd *pw;
  int ch, fd, eval, lockfile = 0;
  uid_t uid;
  const char *from;
  (void)umask(0077);
  openlog("mail.local", LOG_PERROR, LOG_MAIL);
  from = NULL;
  while ((ch = getopt(argc, argv, "ldf:r:")) != -1)
    switch (ch) {
    case 'd':
      break;
    case 'f':
    case 'r':
      if (from)
        logerr(EX_USAGE, "multiple -f options");
      from = optarg;
      break;
    case 'l':
      lockfile++;
      break;
    case '?':
    default:
      usage();
    }
  argc -= optind;
  argv += optind;
  if (!*argv)
    usage();
  uid = getuid();
  if (!from &&
      (!(from = getlogin()) || !(pw = getpwnam(from)) || pw->pw_uid != uid))
    from = (pw = getpwuid(uid)) ? pw->pw_name : "???";
  fd = store(from);
  for (eval = EX_OK; *argv; ++argv) {
    int rval;
    rval = deliver(fd, *argv, lockfile);
    if (eval == EX_OK && rval != EX_OK)
      eval = rval;
  }
  exit(eval);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
mov    $0x3f,%edi
call   1070 <umask@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
mov    0x2db9(%rip),%rax
mov    (%rax),%edx
lea    0xe00(%rip),%rdi
call   10d0 <openlog@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdf0(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     12db <main+0x11b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x3f,%eax
je     12ca <main+0x10a>
jmp    1240 <main+0x80>
mov    -0x40(%rbp),%eax
sub    $0x64,%eax
je     1284 <main+0xc4>
jmp    1251 <main+0x91>
mov    -0x40(%rbp),%eax
sub    $0x66,%eax
je     1289 <main+0xc9>
jmp    1262 <main+0xa2>
mov    -0x40(%rbp),%eax
sub    $0x6c,%eax
je     12bc <main+0xfc>
jmp    1273 <main+0xb3>
mov    -0x40(%rbp),%eax
sub    $0x72,%eax
je     1289 <main+0xc9>
jmp    12cf <main+0x10f>
jmp    12d6 <main+0x116>
cmpq   $0x0,-0x38(%rbp)
je     12a9 <main+0xe9>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xd6e(%rip),%rsi
call   1080 <logerr@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    12d6 <main+0x116>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12d6 <main+0x116>
jmp    12cf <main+0x10f>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    120d <main+0x4d>
mov    0x2cf6(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2ce2(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    131a <main+0x15a>
mov    $0x0,%al
call   10b0 <usage@plt>
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13ad <main+0x1ed>
mov    $0x0,%al
call   1090 <getlogin@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     136d <main+0x1ad>
mov    -0x38(%rbp),%rdi
call   1060 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     136d <main+0x1ad>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x30(%rbp),%rax
je     13ad <main+0x1ed>
mov    -0x30(%rbp),%rdi
call   1040 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1395 <main+0x1d5>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    13a5 <main+0x1e5>
lea    0xc8a(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    13a5 <main+0x1e5>
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <store@plt>
mov    %eax,-0x20(%rbp)
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1428 <main+0x268>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%edx
call   10a0 <deliver@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2bce(%rip),%rcx
cmp    (%rcx),%eax
jne    1412 <main+0x252>
mov    -0x3c(%rbp),%eax
mov    0x2bbc(%rip),%rcx
cmp    (%rcx),%eax
je     1412 <main+0x252>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1417 <main+0x257>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    13c5 <main+0x205>
mov    -0x24(%rbp),%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x3f,%edi
call   1070 <umask@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
lea    0xe2d(%rip),%rdi
call   10d0 <openlog@plt>
lea    0xe2c(%rip),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
jne    1281 <main+0xc1>
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    0x2dbd(%rip),%rax
mov    (%rax),%rbx
cmpq   $0x0,(%r14,%rbx,8)
jne    122c <main+0x6c>
xor    %eax,%eax
call   10b0 <usage@plt>
xor    %eax,%eax
call   1050 <getuid@plt>
test   %r15,%r15
jne    130a <main+0x14a>
mov    %rax,%rbp
xor    %eax,%eax
call   1090 <getlogin@plt>
test   %rax,%rax
je     1264 <main+0xa4>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <getpwnam@plt>
test   %rax,%rax
je     1264 <main+0xa4>
cmp    %rbp,(%rax)
je     130a <main+0x14a>
mov    %rbp,%rdi
call   1040 <getpwuid@plt>
test   %rax,%rax
jne    1306 <main+0x146>
lea    0xdca(%rip),%r15
jmp    130a <main+0x14a>
lea    0xda3(%rip),%r12
lea    0xd71(%rip),%rbx
xor    %r15d,%r15d
xor    %r13d,%r13d
jmp    12c6 <main+0x106>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <usage@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1214 <main+0x54>
add    $0xffffff9c,%eax
ror    %eax
cmp    $0x7,%eax
ja     12a0 <main+0xe0>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
test   %r15,%r15
je     12f3 <main+0x133>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
call   1080 <logerr@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%r15
jmp    12b0 <main+0xf0>
nop
add    $0x1,%r13d
jmp    12b0 <main+0xf0>
mov    0x8(%rax),%r15
mov    %r15,%rdi
call   1030 <store@plt>
mov    0x2ca7(%rip),%r15
mov    (%r15),%ebp
mov    (%r14,%rbx,8),%rsi
test   %rsi,%rsi
je     1354 <main+0x194>
mov    %eax,%r12d
lea    (%r14,%rbx,8),%rbx
add    $0x8,%rbx
mov    %r12d,%edi
mov    %r13d,%edx
call   10a0 <deliver@plt>
mov    (%r15),%ecx
cmp    %ecx,%eax
cmove  %ebp,%eax
cmp    %ecx,%ebp
cmove  %eax,%ebp
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1330 <main+0x170>
mov    %ebp,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i64, i8* }
@.str = [11 x i8] c"mail.local\00"
@LOG_PERROR = global i32 0
@LOG_MAIL = global i32 0
@.str.1 = [7 x i8] c"ldf:r:\00"
@EX_USAGE = global i32 0
@.str.2 = [20 x i8] c"multiple -f options\00"
@optarg = global i8* null
@optind = global i64 0
@.str.3 = [4 x i8] c"???\00"
@EX_OK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%14 = call i32 @umask(i32 63)
%15 = load i32, i32* @LOG_PERROR
%16 = load i32, i32* @LOG_MAIL
%17 = call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
store i8* null, i8** %12
br label %18
18: ; preds = %40, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %7
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %41
23: ; preds = %18
%24 = load i32, i32* %7
switch i32 %24, label %38 [
i32 100, label %25
i32 102, label %26
i32 114, label %26
i32 108, label %34
i32 63, label %37
]
25: ; preds = %23
br label %40
26: ; preds = %23, %23
%27 = load i8*, i8** %12
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @EX_USAGE
%31 = call i32 @logerr(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %29, %26
%33 = load i8*, i8** @optarg
store i8* %33, i8** %12
br label %40
34: ; preds = %23
%35 = load i32, i32* %10
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
br label %40
37: ; preds = %23
br label %38
38: ; preds = %23, %37
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %38, %34, %32, %25
br label %18
41: ; preds = %18
%42 = load i64, i64* @optind
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = sub nsw i64 %44, %42
%46 = trunc i64 %45 to i32
store i32 %46, i32* %4
%47 = load i64, i64* @optind
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 %47
store i8** %49, i8*** %5
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = icmp ne i8* %51, null
br i1 %52, label %55, label %53
53: ; preds = %41
%54 = call i32 (...) @usage()
br label %55
55: ; preds = %53, %41
%56 = call i64 (...) @getuid()
store i64 %56, i64* %11
%57 = load i8*, i8** %12
%58 = icmp ne i8* %57, null
br i1 %58, label %83, label %59
59: ; preds = %55
%60 = call i8* (...) @getlogin()
store i8* %60, i8** %12
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %72
62: ; preds = %59
%63 = load i8*, i8** %12
%64 = call %struct.passwd* @getpwnam(i8* %63)
store %struct.passwd* %64, %struct.passwd** %6
%65 = icmp ne %struct.passwd* %64, null
br i1 %65, label %66, label %72
66: ; preds = %62
%67 = load %struct.passwd*, %struct.passwd** %6
%68 = getelementptr inbounds %struct.passwd, %struct.passwd* %67, i32 0, i32 0
%69 = load i64, i64* %68
%70 = load i64, i64* %11
%71 = icmp ne i64 %69, %70
br i1 %71, label %72, label %83
72: ; preds = %66, %62, %59
%73 = load i64, i64* %11
%74 = call %struct.passwd* @getpwuid(i64 %73)
store %struct.passwd* %74, %struct.passwd** %6
%75 = icmp ne %struct.passwd* %74, null
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = load %struct.passwd*, %struct.passwd** %6
%78 = getelementptr inbounds %struct.passwd, %struct.passwd* %77, i32 0, i32 1
%79 = load i8*, i8** %78
br label %81
80: ; preds = %72
br label %81
81: ; preds = %80, %76
%82 = phi i8* [ %79, %76 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %80 ]
store i8* %82, i8** %12
br label %83
83: ; preds = %81, %66, %55
%84 = load i8*, i8** %12
%85 = call i32 @store(i8* %84)
store i32 %85, i32* %8
%86 = load i32, i32* @EX_OK
store i32 %86, i32* %9
br label %87
87: ; preds = %107, %83
%88 = load i8**, i8*** %5
%89 = load i8*, i8** %88
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %110
91: ; preds = %87
%92 = load i32, i32* %8
%93 = load i8**, i8*** %5
%94 = load i8*, i8** %93
%95 = load i32, i32* %10
%96 = call i32 @deliver(i32 %92, i8* %94, i32 %95)
store i32 %96, i32* %13
%97 = load i32, i32* %9
%98 = load i32, i32* @EX_OK
%99 = icmp eq i32 %97, %98
br i1 %99, label %100, label %106
100: ; preds = %91
%101 = load i32, i32* %13
%102 = load i32, i32* @EX_OK
%103 = icmp ne i32 %101, %102
br i1 %103, label %104, label %106
104: ; preds = %100
%105 = load i32, i32* %13
store i32 %105, i32* %9
br label %106
106: ; preds = %104, %100, %91
br label %107
107: ; preds = %106
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i32 1
store i8** %109, i8*** %5
br label %87
110: ; preds = %87
%111 = load i32, i32* %9
%112 = call i32 @exit(i32 %111)
unreachable
}

LLVM IR (-O2):
%struct.passwd = type { i64, i8* }
@.str = [11 x i8] c"mail.local\00"
@LOG_PERROR = global i32 0
@LOG_MAIL = global i32 0
@.str.1 = [7 x i8] c"ldf:r:\00"
@EX_USAGE = global i32 0
@.str.2 = [20 x i8] c"multiple -f options\00"
@optarg = global i8* null
@optind = global i64 0
@.str.3 = [4 x i8] c"???\00"
@EX_OK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @umask(i32 63)
%4 = load i32, i32* @LOG_PERROR
%5 = load i32, i32* @LOG_MAIL
%6 = tail call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %31, label %9
9: ; preds = %2, %26
%10 = phi i32 [ %29, %26 ], [ %7, %2 ]
%11 = phi i8* [ %28, %26 ], [ null, %2 ]
%12 = phi i32 [ %27, %26 ], [ 0, %2 ]
%13 = add i32 %10, -100
%14 = tail call i32 @llvm.fshl.i32(i32 %13, i32 %13, i32 31)
switch i32 %14, label %24 [
i32 0, label %26
i32 1, label %15
i32 7, label %15
i32 4, label %22
]
15: ; preds = %9, %9
%16 = icmp eq i8* %11, null
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = load i32, i32* @EX_USAGE
%19 = tail call i32 @logerr(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %17, %15
%21 = load i8*, i8** @optarg
br label %26
22: ; preds = %9
%23 = add nsw i32 %12, 1
br label %26
24: ; preds = %9
%25 = tail call i32 (...) @usage()
br label %26
26: ; preds = %24, %22, %20, %9
%27 = phi i32 [ %12, %24 ], [ %23, %22 ], [ %12, %20 ], [ %12, %9 ]
%28 = phi i8* [ %11, %24 ], [ %11, %22 ], [ %21, %20 ], [ %11, %9 ]
%29 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %9
31: ; preds = %26, %2
%32 = phi i32 [ 0, %2 ], [ %27, %26 ]
%33 = phi i8* [ null, %2 ], [ %28, %26 ]
%34 = load i64, i64* @optind
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = tail call i32 (...) @usage()
br label %40
40: ; preds = %38, %31
%41 = tail call i64 (...) @getuid()
%42 = icmp eq i8* %33, null
br i1 %42, label %43, label %59
43: ; preds = %40
%44 = tail call i8* (...) @getlogin()
%45 = icmp eq i8* %44, null
br i1 %45, label %53, label %46
46: ; preds = %43
%47 = tail call %struct.passwd* @getpwnam(i8* %44)
%48 = icmp eq %struct.passwd* %47, null
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = getelementptr inbounds %struct.passwd, %struct.passwd* %47, i64 0, i32 0
%51 = load i64, i64* %50
%52 = icmp eq i64 %51, %41
br i1 %52, label %59, label %53
53: ; preds = %49, %46, %43
%54 = tail call %struct.passwd* @getpwuid(i64 %41)
%55 = icmp eq %struct.passwd* %54, null
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = getelementptr inbounds %struct.passwd, %struct.passwd* %54, i64 0, i32 1
%58 = load i8*, i8** %57
br label %59
59: ; preds = %56, %53, %49, %40
%60 = phi i8* [ %33, %40 ], [ %44, %49 ], [ %58, %56 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %53 ]
%61 = tail call i32 @store(i8* %60)
%62 = load i32, i32* @EX_OK
%63 = load i8*, i8** %35
%64 = icmp eq i8* %63, null
br i1 %64, label %78, label %65
65: ; preds = %59, %65
%66 = phi i8* [ %76, %65 ], [ %63, %59 ]
%67 = phi i8** [ %75, %65 ], [ %35, %59 ]
%68 = phi i32 [ %74, %65 ], [ %62, %59 ]
%69 = tail call i32 @deliver(i32 %61, i8* %66, i32 %32)
%70 = load i32, i32* @EX_OK
%71 = icmp ne i32 %68, %70
%72 = icmp eq i32 %69, %70
%73 = select i1 %71, i1 true, i1 %72
%74 = select i1 %73, i32 %68, i32 %69
%75 = getelementptr inbounds i8*, i8** %67, i64 1
%76 = load i8*, i8** %75
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %65
78: ; preds = %65, %59
%79 = phi i32 [ %62, %59 ], [ %74, %65 ]
%80 = tail call i32 @exit(i32 %79)
unreachable
}