#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*/ strcmp(char *, char *);
char *parse_format(char *format) {
  char *new_format = format;
  if (!strcmp(format, "rsyslog")) {
    new_format = "%b %e %H:%M:%S";
  } else if (!strcmp(format, "apache")) {
    new_format = "%d/%b/%Y:%H:%M:%S";
  } else if (!strcmp(format, "rfc3339")) {
    new_format = "%Y-%m-%dT%H:%M:%S";
  }
  return new_format;
}


x86 assembly (clang, -O0):
<parse_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    114d <parse_format+0x3d>
lea    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11a4 <parse_format+0x94>
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1176 <parse_format+0x66>
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119f <parse_format+0x8f>
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119a <parse_format+0x8a>
lea    0xea2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119f <parse_format+0x8f>
jmp    11a4 <parse_format+0x94>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_format>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1155 <parse_format+0x45>
lea    0xeec(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     115e <parse_format+0x4e>
lea    0xef2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
lea    0xee9(%rip),%rax
cmovne %rbx,%rax
pop    %rbx
ret
lea    0xeac(%rip),%rax
pop    %rbx
ret
lea    0xeb9(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"rsyslog\00"
@.str.1 = [15 x i8] c"%b %e %H:%M:%S\00"
@.str.2 = [7 x i8] c"apache\00"
@.str.3 = [18 x i8] c"%d/%b/%Y:%H:%M:%S\00"
@.str.4 = [8 x i8] c"rfc3339\00"
@.str.5 = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
define i8* @parse_format(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %2
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %21
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %20
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %19
19: ; preds = %18, %14
br label %20
20: ; preds = %19, %13
br label %21
21: ; preds = %20, %8
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [8 x i8] c"rsyslog\00"
@.str.1 = [15 x i8] c"%b %e %H:%M:%S\00"
@.str.2 = [7 x i8] c"apache\00"
@.str.3 = [18 x i8] c"%d/%b/%Y:%H:%M:%S\00"
@.str.4 = [8 x i8] c"rfc3339\00"
@.str.5 = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
define i8* @parse_format(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %0
br label %11
11: ; preds = %7, %4, %1
%12 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %4 ], [ %10, %7 ]
ret i8* %12
}