#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*/ carmen_disable_handlers();
int carmen_ipc_connect_locked(char *);
int /*<<< orphan*/ carmen_set_blogfile_fast();
int /*<<< orphan*/ carmen_set_input_blogfile(char *);
int /*<<< orphan*/ carmen_set_output_blogfile(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ strcmp(char *, char *);
void carmen_ipc_initialize_locked(int argc, char **argv) {
  int err, i;
  err = carmen_ipc_connect_locked(argv[0]);
  if (err < 0)
    exit(1);
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-fast") == 0)
      carmen_set_blogfile_fast();
    if (strcmp(argv[i], "-input_log") == 0 && i < argc - 1 &&
        argv[i + 1][0] != '-')
      carmen_set_input_blogfile(argv[i + 1]);
    else if (strcmp(argv[i], "-output_log") == 0 && i < argc - 1 &&
             argv[i + 1][0] != '-')
      carmen_set_output_blogfile(argv[i + 1]);
    else if (strcmp(argv[i], "-no_handlers") == 0)
      carmen_disable_handlers();
  }
}


x86 assembly (clang, -O0):
<carmen_ipc_initialize_locked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <carmen_ipc_connect_locked@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11a2 <carmen_ipc_initialize_locked+0x32>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12fa <carmen_ipc_initialize_locked+0x18a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11de <carmen_ipc_initialize_locked+0x6e>
mov    $0x0,%al
call   1040 <carmen_set_blogfile_fast@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe15(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <carmen_ipc_initialize_locked+0xd9>
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1249 <carmen_ipc_initialize_locked+0xd9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1249 <carmen_ipc_initialize_locked+0xd9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <carmen_set_input_blogfile@plt>
jmp    12e7 <carmen_ipc_initialize_locked+0x177>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb5(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12b4 <carmen_ipc_initialize_locked+0x144>
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12b4 <carmen_ipc_initialize_locked+0x144>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     12b4 <carmen_ipc_initialize_locked+0x144>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <carmen_set_output_blogfile@plt>
jmp    12e2 <carmen_ipc_initialize_locked+0x172>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12dd <carmen_ipc_initialize_locked+0x16d>
mov    $0x0,%al
call   1030 <carmen_disable_handlers@plt>
jmp    12e2 <carmen_ipc_initialize_locked+0x172>
jmp    12e7 <carmen_ipc_initialize_locked+0x177>
jmp    12ec <carmen_ipc_initialize_locked+0x17c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a9 <carmen_ipc_initialize_locked+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carmen_ipc_initialize_locked>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
mov    (%rsi),%rdi
call   1070 <carmen_ipc_connect_locked@plt>
test   %eax,%eax
js     1268 <carmen_ipc_initialize_locked+0xf8>
cmp    $0x2,%r14d
jl     1259 <carmen_ipc_initialize_locked+0xe9>
lea    -0x1(%r14),%ebp
mov    %r14d,%r13d
mov    $0x1,%r12d
lea    0xe51(%rip),%r14
lea    0xe50(%rip),%r15
jmp    11d2 <carmen_ipc_initialize_locked+0x62>
nopl   0x0(%rax,%rax,1)
call   1090 <carmen_set_input_blogfile@plt>
add    $0x1,%r12
cmp    %r12,%r13
je     1259 <carmen_ipc_initialize_locked+0xe9>
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11ea <carmen_ipc_initialize_locked+0x7a>
xor    %eax,%eax
call   1040 <carmen_set_blogfile_fast@plt>
mov    (%rbx,%r12,8),%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    120a <carmen_ipc_initialize_locked+0x9a>
cmp    %rbp,%r12
jae    120a <carmen_ipc_initialize_locked+0x9a>
mov    0x8(%rbx,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
jne    11c0 <carmen_ipc_initialize_locked+0x50>
mov    (%rbx,%r12,8),%rdi
lea    0xdfc(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    122e <carmen_ipc_initialize_locked+0xbe>
cmp    %rbp,%r12
jae    122e <carmen_ipc_initialize_locked+0xbe>
mov    0x8(%rbx,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
jne    124f <carmen_ipc_initialize_locked+0xdf>
mov    (%rbx,%r12,8),%rdi
lea    0xde4(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11c5 <carmen_ipc_initialize_locked+0x55>
xor    %eax,%eax
call   1030 <carmen_disable_handlers@plt>
jmp    11c5 <carmen_ipc_initialize_locked+0x55>
call   1060 <carmen_set_output_blogfile@plt>
jmp    11c5 <carmen_ipc_initialize_locked+0x55>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"-fast\00"
@.str.1 = [11 x i8] c"-input_log\00"
@.str.2 = [12 x i8] c"-output_log\00"
@.str.3 = [13 x i8] c"-no_handlers\00"
define void @carmen_ipc_initialize_locked(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = call i32 @carmen_ipc_connect_locked(i8* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 1, i32* %6
br label %16
16: ; preds = %107, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %110
20: ; preds = %16
%21 = load i8**, i8*** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 (...) @carmen_set_blogfile_fast()
br label %30
30: ; preds = %28, %20
%31 = load i8**, i8*** %4
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %62
38: ; preds = %30
%39 = load i32, i32* %6
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %62
43: ; preds = %38
%44 = load i8**, i8*** %4
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 45
br i1 %53, label %54, label %62
54: ; preds = %43
%55 = load i8**, i8*** %4
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %55, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @carmen_set_input_blogfile(i8* %60)
br label %106
62: ; preds = %43, %38, %30
%63 = load i8**, i8*** %4
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %94
70: ; preds = %62
%71 = load i32, i32* %6
%72 = load i32, i32* %3
%73 = sub nsw i32 %72, 1
%74 = icmp slt i32 %71, %73
br i1 %74, label %75, label %94
75: ; preds = %70
%76 = load i8**, i8*** %4
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %76, i64 %79
%81 = load i8*, i8** %80
%82 = getelementptr inbounds i8, i8* %81, i64 0
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %84, 45
br i1 %85, label %86, label %94
86: ; preds = %75
%87 = load i8**, i8*** %4
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %87, i64 %90
%92 = load i8*, i8** %91
%93 = call i32 @carmen_set_output_blogfile(i8* %92)
br label %105
94: ; preds = %75, %70, %62
%95 = load i8**, i8*** %4
%96 = load i32, i32* %6
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = call i64 @strcmp(i8* %99, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %94
%103 = call i32 (...) @carmen_disable_handlers()
br label %104
104: ; preds = %102, %94
br label %105
105: ; preds = %104, %86
br label %106
106: ; preds = %105, %54
br label %107
107: ; preds = %106
%108 = load i32, i32* %6
%109 = add nsw i32 %108, 1
store i32 %109, i32* %6
br label %16
110: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"-fast\00"
@.str.1 = [11 x i8] c"-input_log\00"
@.str.2 = [12 x i8] c"-output_log\00"
@.str.3 = [13 x i8] c"-no_handlers\00"
define void @carmen_ipc_initialize_locked(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @carmen_ipc_connect_locked(i8* %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %58
8: ; preds = %6
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
%11 = zext i32 %0 to i64
br label %14
12: ; preds = %2
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8, %55
%15 = phi i64 [ 1, %8 ], [ %56, %55 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = tail call i32 (...) @carmen_set_blogfile_fast()
br label %22
22: ; preds = %20, %14
%23 = load i8*, i8** %16
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
%26 = icmp ult i64 %15, %10
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %36
28: ; preds = %22
%29 = add nuw nsw i64 %15, 1
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 45
br i1 %33, label %36, label %34
34: ; preds = %28
%35 = tail call i32 @carmen_set_input_blogfile(i8* %31)
br label %55
36: ; preds = %28, %22
%37 = load i8*, i8** %16
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i1 %26, i1 false
br i1 %40, label %41, label %49
41: ; preds = %36
%42 = add nuw nsw i64 %15, 1
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 45
br i1 %46, label %49, label %47
47: ; preds = %41
%48 = tail call i32 @carmen_set_output_blogfile(i8* %44)
br label %55
49: ; preds = %41, %36
%50 = load i8*, i8** %16
%51 = tail call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = tail call i32 (...) @carmen_disable_handlers()
br label %55
55: ; preds = %34, %49, %53, %47
%56 = add nuw nsw i64 %15, 1
%57 = icmp eq i64 %56, %11
br i1 %57, label %58, label %14
58: ; preds = %55, %6
ret void
}