#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 /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *getlogin();
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int ch;
  char *p;
  setlocale(LC_ALL, "");
  while ((ch = getopt(argc, argv, "")) != -1)
    switch (ch) {
    case '?':
    default:
      usage();
    }
  if (argc != optind) {
    usage();
  }
  if ((p = getlogin()) == NULL)
    err(1, "getlogin");
  (void)printf("%s\n", p);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1060 <setlocale@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe63(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11dc <main+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x3f,%eax
jne    11d0 <main+0x60>
jmp    11cb <main+0x5b>
jmp    11d0 <main+0x60>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    119b <main+0x2b>
mov    -0x8(%rbp),%eax
mov    0x2e02(%rip),%rcx
cmp    (%rcx),%eax
je     11f5 <main+0x85>
mov    $0x0,%al
call   1070 <usage@plt>
mov    $0x0,%al
call   1050 <getlogin@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    121b <main+0xab>
mov    $0x1,%edi
lea    0xdea(%rip),%rsi
call   1040 <err@plt>
mov    -0x20(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%r14
mov    %r14,%rsi
call   1060 <setlocale@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0xffffffff,%eax
je     11c9 <main+0x59>
lea    0xe62(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x40>
mov    0x2e18(%rip),%rax
cmp    %ebp,(%rax)
je     11db <main+0x6b>
xor    %eax,%eax
call   1070 <usage@plt>
xor    %eax,%eax
call   1050 <getlogin@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11fb <main+0x8b>
lea    0xe0f(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
lea    0xe07(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@optind = global i32 0
@.str.1 = [9 x i8] c"getlogin\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @LC_ALL
%9 = call i32 @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %18 [
i32 63, label %17
]
17: ; preds = %15
br label %18
18: ; preds = %15, %17
%19 = call i32 (...) @usage()
br label %20
20: ; preds = %18
br label %10
21: ; preds = %10
%22 = load i32, i32* %4
%23 = load i32, i32* @optind
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @usage()
br label %27
27: ; preds = %25, %21
%28 = call i8* (...) @getlogin()
store i8* %28, i8** %7
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = load i8*, i8** %7
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@optind = global i32 0
@.str.1 = [9 x i8] c"getlogin\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %2, %7
%8 = tail call i32 (...) @usage()
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %7
11: ; preds = %7, %2
%12 = load i32, i32* @optind
%13 = icmp eq i32 %12, %0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 (...) @usage()
br label %16
16: ; preds = %14, %11
%17 = tail call i8* (...) @getlogin()
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%23 = tail call i32 @exit(i32 0)
unreachable
}