#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 */
struct option {
  char *member_0;
  int member_1;
  int /*<<< orphan*/ member_3;
  int /*<<< orphan*/ *member_2;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int __make_local_socket(char *);
int /*<<< orphan*/ __process(int, char *, char *, char *, int);
char *__setup_tempdir(char *, char *);
char *__setup_tempfile(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ optarg;
scalar_t__ optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ *stdin;
char *strdup(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int fd, ch;
  char *msg = NULL, *path = NULL, *tag = NULL, *dir = NULL, *ftemp = NULL;
  FILE *f = NULL;
  struct option long_opts[] = {
      {"tag", 2, NULL, 0},
      {"unix-socket", 2, NULL, 0},
      {"help", 2, NULL, 0},
  };
  while ((ch = getopt_long(argc, argv, "t:u:h", long_opts, NULL)) != -1) {
    switch (ch) {
    case 't':
      tag = strdup(optarg);
      break;
    case 'u':
      path = strdup(optarg);
      break;
    case 'h':
    default:
      usage();
      exit(1);
    }
  }
  argc -= optind;
  argv += optind;
  if (!path || !tag) {
    usage();
    exit(-1);
  }
  dir = __setup_tempdir("/var/run/compostela/tmp", tag);
  if (!dir) {
    perror("comlogger: __setup_temp");
    exit(-1);
  }
  if (argc > 0) {
    int n = strlen(argv[0]);
    msg = malloc(n + 3);
    snprintf(msg, n + 3, "%s\r\n", argv[0]);
  }
  if (!msg) {
    f = stdin;
  }
  fd = __make_local_socket(path);
  if (fd == -1) {
    perror("comlogger: socket");
    exit(-1);
  }
  if (msg) {
    ftemp = __setup_tempfile(dir);
    if (!ftemp) {
      perror("comlogger: __setup_tempfile");
      exit(-1);
    }
    __process(fd, tag, ftemp, msg, strlen(msg));
    free(ftemp);
  } else {
    char buf[8192];
    while (fgets(buf, sizeof(buf), stdin) != NULL) {
      ftemp = __setup_tempfile(dir);
      if (!ftemp) {
        perror("comlogger: __setup_tempfile");
        exit(-1);
      }
      __process(fd, tag, ftemp, buf, strlen(buf));
      free(ftemp);
    }
  }
  free(dir);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1080 <memset@plt>
lea    0xd9d(%rip),%rax
mov    %rax,-0x90(%rbp)
movl   $0x2,-0x88(%rbp)
lea    0xd89(%rip),%rax
mov    %rax,-0x78(%rbp)
movl   $0x2,-0x70(%rbp)
lea    0xd83(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x2,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xd68(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <getopt_long@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     134b <main+0x14b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20a4(%rbp)
sub    $0x68,%eax
je     1330 <main+0x130>
jmp    12da <main+0xda>
mov    -0x20a4(%rbp),%eax
sub    $0x74,%eax
je     1302 <main+0x102>
jmp    12ee <main+0xee>
mov    -0x20a4(%rbp),%eax
sub    $0x75,%eax
je     1319 <main+0x119>
jmp    1335 <main+0x135>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
call   1120 <strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    1346 <main+0x146>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
call   1120 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    1346 <main+0x146>
jmp    1335 <main+0x135>
mov    $0x0,%al
call   10f0 <usage@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1298 <main+0x98>
mov    0x2c86(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2c72(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     138b <main+0x18b>
cmpq   $0x0,-0x30(%rbp)
jne    139c <main+0x19c>
mov    $0x0,%al
call   10f0 <usage@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    -0x30(%rbp),%rsi
lea    0xc74(%rip),%rdi
call   10e0 <__setup_tempdir@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13d1 <main+0x1d1>
lea    0xc71(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    141f <main+0x21f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%edi
add    $0x3,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x94(%rbp),%esi
add    $0x3,%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xc31(%rip),%rdx
call   1060 <snprintf@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1438 <main+0x238>
mov    0x2baf(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <__make_local_socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1464 <main+0x264>
lea    0xbfb(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
je     1501 <main+0x301>
mov    -0x38(%rbp),%rdi
call   1070 <__setup_tempfile@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    149d <main+0x29d>
lea    0xbd4(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20c4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20c0(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x20b8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x20b0(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20c4(%rbp),%edi
mov    -0x20c0(%rbp),%rsi
mov    -0x20b8(%rbp),%rdx
mov    -0x20b0(%rbp),%rcx
mov    %eax,%r8d
call   10b0 <__process@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    15c8 <main+0x3c8>
jmp    1506 <main+0x306>
lea    -0x20a0(%rbp),%rdi
mov    0x2acc(%rip),%rax
mov    (%rax),%rdx
mov    $0x2000,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     15c3 <main+0x3c3>
mov    -0x38(%rbp),%rdi
call   1070 <__setup_tempfile@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1559 <main+0x359>
lea    0xb18(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20e4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20e0(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x20d8(%rbp)
lea    -0x20a0(%rbp),%rax
mov    %rax,-0x20d0(%rbp)
lea    -0x20a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20e4(%rbp),%edi
mov    -0x20e0(%rbp),%rsi
mov    -0x20d8(%rbp),%rdx
mov    -0x20d0(%rbp),%rcx
mov    %eax,%r8d
call   10b0 <__process@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    1506 <main+0x306>
jmp    15c8 <main+0x3c8>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x20f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2068,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movq   $0x0,0x50(%rsp)
lea    0xdd3(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x2,0x18(%rsp)
lea    0xdc3(%rip),%rax
mov    %rax,0x28(%rsp)
movl   $0x2,0x30(%rsp)
lea    0xdbb(%rip),%rax
mov    %rax,0x40(%rsp)
movl   $0x2,0x48(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xda5(%rip),%r14
lea    0x10(%rsp),%r13
mov    0x2d7c(%rip),%r12
xor    %r15d,%r15d
jmp    129c <main+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
call   1110 <strdup@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1050 <getopt_long@plt>
cmp    $0x74,%eax
je     1290 <main+0xa0>
cmp    $0xffffffff,%eax
je     12d2 <main+0xe2>
cmp    $0x75,%eax
jne    144e <main+0x25e>
mov    (%r12),%edi
call   1110 <strdup@plt>
mov    %rax,0x8(%rsp)
jmp    129c <main+0xac>
cmpq   $0x0,0x8(%rsp)
je     1475 <main+0x285>
test   %r15,%r15
je     1475 <main+0x285>
mov    0x2cea(%rip),%rax
mov    (%rax),%r13
lea    0xd23(%rip),%rdi
mov    %r15,%rsi
call   10d0 <__setup_tempdir@plt>
test   %rax,%rax
je     1486 <main+0x296>
mov    %rax,%r14
sub    %r13d,%ebp
test   %ebp,%ebp
jle    139a <main+0x1aa>
mov    (%rbx,%r13,8),%rdi
call   1040 <strlen@plt>
lea    0x3(%rax),%ebp
mov    %ebp,%edi
call   10c0 <malloc@plt>
mov    %rax,%r12
mov    (%rbx,%r13,8),%rcx
lea    0xd13(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
call   1060 <snprintf@plt>
mov    0x8(%rsp),%rdi
call   10b0 <__make_local_socket@plt>
cmp    $0xffffffff,%eax
je     148f <main+0x29f>
mov    %eax,%r13d
test   %r12,%r12
je     13b0 <main+0x1c0>
mov    %r14,%rdi
call   1070 <__setup_tempfile@plt>
test   %rax,%rax
je     145f <main+0x26f>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %eax,%r8d
call   10a0 <__process@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    142a <main+0x23a>
mov    0x8(%rsp),%rdi
call   10b0 <__make_local_socket@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
je     148f <main+0x29f>
mov    0x2c29(%rip),%r12
mov    (%r12),%rdx
lea    0x60(%rsp),%rdi
mov    $0x2000,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     142a <main+0x23a>
lea    0x60(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1070 <__setup_tempfile@plt>
test   %rax,%rax
je     145f <main+0x26f>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %eax,%r8d
call   10a0 <__process@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r12),%rdx
mov    %rbp,%rdi
mov    $0x2000,%esi
call   1090 <fgets@plt>
test   %rax,%rax
jne    13e0 <main+0x1f0>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x2068,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10e0 <usage@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xbfc(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    0xba6(%rip),%rdi
jmp    1466 <main+0x276>
lea    0xbba(%rip),%rdi
jmp    1466 <main+0x276>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i32, i32* }
@.str = [4 x i8] c"tag\00"
@.str.1 = [12 x i8] c"unix-socket\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [6 x i8] c"t:u:h\00"
@optarg = global i32 0
@optind = global i64 0
@.str.4 = [24 x i8] c"/var/run/compostela/tmp\00"
@.str.5 = [24 x i8] c"comlogger: __setup_temp\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
@stdin = global i32* null
@.str.7 = [18 x i8] c"comlogger: socket\00"
@.str.8 = [28 x i8] c"comlogger: __setup_tempfile\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 i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca [3 x %struct.option]
%15 = alloca i32
%16 = alloca [8192 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32* null, i32** %13
%17 = bitcast [3 x %struct.option]* %14 to i8*
%18 = bitcast i8* %17 to [3 x %struct.option]*
%19 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %18, i32 0, i32 0
%20 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds %struct.option, %struct.option* %19, i32 0, i32 1
store i32 2, i32* %21
%22 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %18, i32 0, i32 1
%23 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds %struct.option, %struct.option* %22, i32 0, i32 1
store i32 2, i32* %24
%25 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %18, i32 0, i32 2
%26 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8** %26
%27 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 1
store i32 2, i32* %27
br label %28
28: ; preds = %46, %2
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %14, i64 0, i64 0
%32 = call i32 @getopt_long(i32 %29, i8** %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %31, i32* null)
store i32 %32, i32* %7
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %47
34: ; preds = %28
%35 = load i32, i32* %7
switch i32 %35, label %43 [
i32 116, label %36
i32 117, label %39
i32 104, label %42
]
36: ; preds = %34
%37 = load i32, i32* @optarg
%38 = call i8* @strdup(i32 %37)
store i8* %38, i8** %10
br label %46
39: ; preds = %34
%40 = load i32, i32* @optarg
%41 = call i8* @strdup(i32 %40)
store i8* %41, i8** %9
br label %46
42: ; preds = %34
br label %43
43: ; preds = %34, %42
%44 = call i32 (...) @usage()
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39, %36
br label %28
47: ; preds = %28
%48 = load i64, i64* @optind
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = sub nsw i64 %50, %48
%52 = trunc i64 %51 to i32
store i32 %52, i32* %4
%53 = load i64, i64* @optind
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 %53
store i8** %55, i8*** %5
%56 = load i8*, i8** %9
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %61
58: ; preds = %47
%59 = load i8*, i8** %10
%60 = icmp ne i8* %59, null
br i1 %60, label %64, label %61
61: ; preds = %58, %47
%62 = call i32 (...) @usage()
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %58
%65 = load i8*, i8** %10
%66 = call i8* @__setup_tempdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %65)
store i8* %66, i8** %11
%67 = load i8*, i8** %11
%68 = icmp ne i8* %67, null
br i1 %68, label %72, label %69
69: ; preds = %64
%70 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%71 = call i32 @exit(i32 -1)
unreachable
72: ; preds = %64
%73 = load i32, i32* %4
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %90
75: ; preds = %72
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 0
%78 = load i8*, i8** %77
%79 = call i32 @strlen(i8* %78)
store i32 %79, i32* %15
%80 = load i32, i32* %15
%81 = add nsw i32 %80, 3
%82 = call i8* @malloc(i32 %81)
store i8* %82, i8** %8
%83 = load i8*, i8** %8
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 3
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 0
%88 = load i8*, i8** %87
%89 = call i32 @snprintf(i8* %83, i32 %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %75, %72
%91 = load i8*, i8** %8
%92 = icmp ne i8* %91, null
br i1 %92, label %95, label %93
93: ; preds = %90
%94 = load i32*, i32** @stdin
store i32* %94, i32** %13
br label %95
95: ; preds = %93, %90
%96 = load i8*, i8** %9
%97 = call i32 @__make_local_socket(i8* %96)
store i32 %97, i32* %6
%98 = load i32, i32* %6
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%102 = call i32 @exit(i32 -1)
unreachable
103: ; preds = %95
%104 = load i8*, i8** %8
%105 = icmp ne i8* %104, null
br i1 %105, label %106, label %124
106: ; preds = %103
%107 = load i8*, i8** %11
%108 = call i8* @__setup_tempfile(i8* %107)
store i8* %108, i8** %12
%109 = load i8*, i8** %12
%110 = icmp ne i8* %109, null
br i1 %110, label %114, label %111
111: ; preds = %106
%112 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%113 = call i32 @exit(i32 -1)
unreachable
114: ; preds = %106
%115 = load i32, i32* %6
%116 = load i8*, i8** %10
%117 = load i8*, i8** %12
%118 = load i8*, i8** %8
%119 = load i8*, i8** %8
%120 = call i32 @strlen(i8* %119)
%121 = call i32 @__process(i32 %115, i8* %116, i8* %117, i8* %118, i32 %120)
%122 = load i8*, i8** %12
%123 = call i32 @free(i8* %122)
br label %149
124: ; preds = %103
br label %125
125: ; preds = %138, %124
%126 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 0
%127 = load i32*, i32** @stdin
%128 = call i32* @fgets(i8* %126, i32 8192, i32* %127)
%129 = icmp ne i32* %128, null
br i1 %129, label %130, label %148
130: ; preds = %125
%131 = load i8*, i8** %11
%132 = call i8* @__setup_tempfile(i8* %131)
store i8* %132, i8** %12
%133 = load i8*, i8** %12
%134 = icmp ne i8* %133, null
br i1 %134, label %138, label %135
135: ; preds = %130
%136 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%137 = call i32 @exit(i32 -1)
unreachable
138: ; preds = %130
%139 = load i32, i32* %6
%140 = load i8*, i8** %10
%141 = load i8*, i8** %12
%142 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 0
%143 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 0
%144 = call i32 @strlen(i8* %143)
%145 = call i32 @__process(i32 %139, i8* %140, i8* %141, i8* %142, i32 %144)
%146 = load i8*, i8** %12
%147 = call i32 @free(i8* %146)
br label %125
148: ; preds = %125
br label %149
149: ; preds = %148, %114
%150 = load i8*, i8** %11
%151 = call i32 @free(i8* %150)
%152 = load i32, i32* %6
%153 = call i32 @close(i32 %152)
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i32, i32* }
@.str = [4 x i8] c"tag\00"
@.str.1 = [12 x i8] c"unix-socket\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [6 x i8] c"t:u:h\00"
@optarg = global i32 0
@optind = global i64 0
@.str.4 = [24 x i8] c"/var/run/compostela/tmp\00"
@.str.5 = [24 x i8] c"comlogger: __setup_temp\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
@stdin = global i32* null
@.str.7 = [18 x i8] c"comlogger: socket\00"
@.str.8 = [28 x i8] c"comlogger: __setup_tempfile\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [3 x %struct.option]
%4 = alloca [8192 x i8]
%5 = bitcast [3 x %struct.option]* %3 to i8*
%6 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0, i32 1
store i32 2, i32* %7
%8 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 1, i32 1
store i32 2, i32* %9
%10 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 2, i32 1
store i32 2, i32* %11
%12 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %3, i64 0, i64 0
br label %13
13: ; preds = %22, %2
%14 = phi i8* [ %24, %22 ], [ null, %2 ]
%15 = phi i8* [ %17, %22 ], [ null, %2 ]
br label %16
16: ; preds = %13, %19
%17 = phi i8* [ %21, %19 ], [ %15, %13 ]
%18 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %12, i32* null)
switch i32 %18, label %25 [
i32 -1, label %28
i32 116, label %19
i32 117, label %22
]
19: ; preds = %16
%20 = load i32, i32* @optarg
%21 = call i8* @strdup(i32 %20)
br label %16
22: ; preds = %16
%23 = load i32, i32* @optarg
%24 = call i8* @strdup(i32 %23)
br label %13
25: ; preds = %16
%26 = call i32 (...) @usage()
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %16
%29 = load i64, i64* @optind
%30 = trunc i64 %29 to i32
%31 = sub i32 %0, %30
%32 = getelementptr inbounds i8*, i8** %1, i64 %29
%33 = icmp ne i8* %14, null
%34 = icmp ne i8* %17, null
%35 = select i1 %33, i1 %34, i1 false
br i1 %35, label %39, label %36
36: ; preds = %28
%37 = call i32 (...) @usage()
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %28
%40 = call i8* @__setup_tempdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %39
%46 = icmp sgt i32 %31, 0
br i1 %46, label %47, label %56
47: ; preds = %45
%48 = load i8*, i8** %32
%49 = call i32 @strlen(i8* %48)
%50 = add nsw i32 %49, 3
%51 = call i8* @malloc(i32 %50)
%52 = load i8*, i8** %32
%53 = call i32 @snprintf(i8* %51, i32 %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = call i32 @__make_local_socket(i8* %14)
%55 = icmp eq i32 %54, -1
br i1 %55, label %59, label %62
56: ; preds = %45
%57 = call i32 @__make_local_socket(i8* %14)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %74
59: ; preds = %56, %47
%60 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %47
%63 = icmp eq i8* %51, null
br i1 %63, label %74, label %64
64: ; preds = %62
%65 = call i8* @__setup_tempfile(i8* %40)
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%69 = call i32 @exit(i32 -1)
unreachable
70: ; preds = %64
%71 = call i32 @strlen(i8* %51)
%72 = call i32 @__process(i32 %54, i8* %17, i8* %65, i8* %51, i32 %71)
%73 = call i32 @free(i8* %65)
br label %94
74: ; preds = %56, %62
%75 = phi i32 [ %54, %62 ], [ %57, %56 ]
%76 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%77 = load i32*, i32** @stdin
%78 = call i32* @fgets(i8* %76, i32 8192, i32* %77)
%79 = icmp eq i32* %78, null
br i1 %79, label %93, label %80
80: ; preds = %74, %86
%81 = call i8* @__setup_tempfile(i8* %40)
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%85 = call i32 @exit(i32 -1)
unreachable
86: ; preds = %80
%87 = call i32 @strlen(i8* %76)
%88 = call i32 @__process(i32 %75, i8* %17, i8* %81, i8* %76, i32 %87)
%89 = call i32 @free(i8* %81)
%90 = load i32*, i32** @stdin
%91 = call i32* @fgets(i8* %76, i32 8192, i32* %90)
%92 = icmp eq i32* %91, null
br i1 %92, label %93, label %80
93: ; preds = %86, %74
br label %94
94: ; preds = %93, %70
%95 = phi i32 [ %75, %93 ], [ %54, %70 ]
%96 = call i32 @free(i8* %40)
%97 = call i32 @close(i32 %95)
ret i32 0
}