#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*/ LOG_INFO;
int /*<<< orphan*/ daemonize(char *);
int /*<<< orphan*/ getlogin();
char *strrchr(char *, char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *pcmd;
  pcmd = strrchr(argv[0], '/');
  if (pcmd == NULL)
    pcmd = argv[0];
  pcmd++;
  daemonize(pcmd);
  syslog(LOG_INFO, "getlogin=%s\n", getlogin());
  return 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    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <daemonize@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <getlogin@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe4b(%rip),%rsi
call   1050 <syslog@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    (%rsi),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
cmovne %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <daemonize@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1060 <getlogin@plt>
lea    0xe85(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <syslog@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [13 x i8] c"getlogin=%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i8* @strrchr(i8* %9, i8 signext 47)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
store i8* %16, i8** %6
br label %17
17: ; preds = %13, %2
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @daemonize(i8* %20)
%22 = load i32, i32* @LOG_INFO
%23 = call i32 (...) @getlogin()
%24 = call i32 @syslog(i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [13 x i8] c"getlogin=%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = select i1 %5, i8* %3, i8* %4
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = tail call i32 @daemonize(i8* %7)
%9 = load i32, i32* @LOG_INFO
%10 = tail call i32 (...) @getlogin()
%11 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}