#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ generate_c_header(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ generate_c_source(char const *, char const *,
                                     int /*<<< orphan*/ *);
char *strrchr(char const *, char);
void generate_c(const char *output_c_name, FILE *output_c,
                const char *output_h_name, FILE *output_h) {
  char *ptr;
  ptr = strrchr(output_c_name, '/');
  if (!ptr)
    ptr = strrchr(output_c_name, '\\');
  if (ptr)
    output_c_name = ptr + 1;
  ptr = strrchr(output_h_name, '/');
  if (!ptr)
    ptr = strrchr(output_h_name, '\\');
  if (ptr)
    output_h_name = ptr + 1;
  generate_c_header(output_h_name, output_h);
  generate_c_source(output_c_name, output_h_name, output_c);
}


x86 assembly (clang, -O0):
<generate_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1177 <generate_c+0x47>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118e <generate_c+0x5e>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bd <generate_c+0x8d>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11d4 <generate_c+0xa4>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <generate_c_header@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <generate_c_source@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_c>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r13
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1169 <generate_c+0x39>
mov    %r13,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    1188 <generate_c+0x58>
mov    %r12,%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
lea    0x1(%rbx),%rbp
test   %rbx,%rbx
cmove  %r13,%rbp
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %r12,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <generate_c_header@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <generate_c_source@plt>

LLVM IR (-O0):
define void @generate_c(i8* %0, i32* %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%10 = load i8*, i8** %5
%11 = call i8* @strrchr(i8* %10, i8 signext 47)
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load i8*, i8** %5
%16 = call i8* @strrchr(i8* %15, i8 signext 92)
store i8* %16, i8** %9
br label %17
17: ; preds = %14, %4
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %5
br label %23
23: ; preds = %20, %17
%24 = load i8*, i8** %7
%25 = call i8* @strrchr(i8* %24, i8 signext 47)
store i8* %25, i8** %9
%26 = load i8*, i8** %9
%27 = icmp ne i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = call i8* @strrchr(i8* %29, i8 signext 92)
store i8* %30, i8** %9
br label %31
31: ; preds = %28, %23
%32 = load i8*, i8** %9
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** %9
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %7
br label %37
37: ; preds = %34, %31
%38 = load i8*, i8** %7
%39 = load i32*, i32** %8
%40 = call i32 @generate_c_header(i8* %38, i32* %39)
%41 = load i8*, i8** %5
%42 = load i8*, i8** %7
%43 = load i32*, i32** %6
%44 = call i32 @generate_c_source(i8* %41, i8* %42, i32* %43)
ret void
}

LLVM IR (-O2):
define void @generate_c(i8* %0, i32* %1, i8* %2, i32* %3) {
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 92)
br label %9
9: ; preds = %7, %4
%10 = phi i8* [ %5, %4 ], [ %8, %7 ]
%11 = tail call i8* @strrchr(i8* dereferenceable(1) %2, i8 signext 47)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i8* @strrchr(i8* dereferenceable(1) %2, i8 signext 92)
br label %15
15: ; preds = %13, %9
%16 = phi i8* [ %11, %9 ], [ %14, %13 ]
%17 = icmp eq i8* %10, null
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = select i1 %17, i8* %0, i8* %18
%20 = icmp eq i8* %16, null
%21 = getelementptr inbounds i8, i8* %16, i64 1
%22 = select i1 %20, i8* %2, i8* %21
%23 = tail call i32 @generate_c_header(i8* %22, i32* %3)
%24 = tail call i32 @generate_c_source(i8* %19, i8* %22, i32* %1)
ret void
}