#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 params {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ copy_body();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ free_params(struct params *);
scalar_t__ read_func_header(char **, struct params **, struct params **);
char *read_package();
int /*<<< orphan*/ read_preprocessor_lines();
char *strchr(char *, char);
int /*<<< orphan*/ write_func_header(char *, char *, struct params *,
                                     struct params *);
int /*<<< orphan*/ write_func_trailer(char *, char *, struct params *);
void process_file(void) {
  char *package, *name;
  struct params *params, *rets;
  package = read_package();
  read_preprocessor_lines();
  while (read_func_header(&name, &params, &rets)) {
    char *p;
    char *pkg;
    char *nm;
    p = strchr(name, '.');
    if (p == NULL) {
      pkg = package;
      nm = name;
    } else {
      pkg = name;
      nm = p + 1;
      *p = '\0';
    }
    write_func_header(pkg, nm, params, rets);
    copy_body();
    write_func_trailer(pkg, nm, rets);
    free(name);
    free_params(params);
    free_params(rets);
  }
  free(package);
}


x86 assembly (clang, -O0):
<process_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   10a0 <read_package@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <read_preprocessor_lines@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1070 <read_func_header@plt>
cmp    $0x0,%rax
je     125f <process_file+0xcf>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f7 <process_file+0x67>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1212 <process_file+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <write_func_header@plt>
mov    $0x0,%al
call   10b0 <copy_body@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <write_func_trailer@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <free_params@plt>
mov    -0x20(%rbp),%rdi
call   1060 <free_params@plt>
jmp    11aa <process_file+0x1a>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   10a0 <read_package@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <read_preprocessor_lines@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <read_func_header@plt>
test   %rax,%rax
je     1263 <process_file+0xd3>
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
mov    %rsp,%r13
jmp    1247 <process_file+0xb7>
nopl   0x0(%rax)
mov    %rbx,%rbp
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <write_func_header@plt>
xor    %eax,%eax
call   10b0 <copy_body@plt>
mov    (%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <write_func_trailer@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1060 <free_params@plt>
mov    (%rsp),%rdi
call   1060 <free_params@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1070 <read_func_header@plt>
test   %rax,%rax
je     1263 <process_file+0xd3>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    11e0 <process_file+0x50>
mov    %r14,%rbp
jmp    11ed <process_file+0x5d>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.params = type { i32 }
define void @process_file() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca %struct.params*
%4 = alloca %struct.params*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = call i8* (...) @read_package()
store i8* %8, i8** %1
%9 = call i32 (...) @read_preprocessor_lines()
br label %10
10: ; preds = %26, %0
%11 = call i64 @read_func_header(i8** %2, %struct.params** %3, %struct.params** %4)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %43
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = call i8* @strchr(i8* %14, i8 signext 46)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %1
store i8* %19, i8** %6
%20 = load i8*, i8** %2
store i8* %20, i8** %7
br label %26
21: ; preds = %13
%22 = load i8*, i8** %2
store i8* %22, i8** %6
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %7
%25 = load i8*, i8** %5
store i8 0, i8* %25
br label %26
26: ; preds = %21, %18
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = load %struct.params*, %struct.params** %3
%30 = load %struct.params*, %struct.params** %4
%31 = call i32 @write_func_header(i8* %27, i8* %28, %struct.params* %29, %struct.params* %30)
%32 = call i32 (...) @copy_body()
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = load %struct.params*, %struct.params** %4
%36 = call i32 @write_func_trailer(i8* %33, i8* %34, %struct.params* %35)
%37 = load i8*, i8** %2
%38 = call i32 @free(i8* %37)
%39 = load %struct.params*, %struct.params** %3
%40 = call i32 @free_params(%struct.params* %39)
%41 = load %struct.params*, %struct.params** %4
%42 = call i32 @free_params(%struct.params* %41)
br label %10
43: ; preds = %10
%44 = load i8*, i8** %1
%45 = call i32 @free(i8* %44)
ret void
}

LLVM IR (-O2):
%struct.params = type { i32 }
define void @process_file() {
%1 = alloca i8*
%2 = alloca %struct.params*
%3 = alloca %struct.params*
%4 = bitcast i8** %1 to i8*
%5 = bitcast %struct.params** %2 to i8*
%6 = bitcast %struct.params** %3 to i8*
%7 = tail call i8* (...) @read_package()
%8 = tail call i32 (...) @read_preprocessor_lines()
%9 = call i64 @read_func_header(i8** %1, %struct.params** %2, %struct.params** %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %34, label %11
11: ; preds = %0, %17
%12 = load i8*, i8** %1
%13 = call i8* @strchr(i8* dereferenceable(1) %12, i8 signext 46)
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %13, i64 1
store i8 0, i8* %13
br label %17
17: ; preds = %11, %15
%18 = phi i8* [ %12, %15 ], [ %7, %11 ]
%19 = phi i8* [ %16, %15 ], [ %12, %11 ]
%20 = load %struct.params*, %struct.params** %2
%21 = load %struct.params*, %struct.params** %3
%22 = call i32 @write_func_header(i8* %18, i8* %19, %struct.params* %20, %struct.params* %21)
%23 = call i32 (...) @copy_body()
%24 = load %struct.params*, %struct.params** %3
%25 = call i32 @write_func_trailer(i8* %18, i8* %19, %struct.params* %24)
%26 = load i8*, i8** %1
%27 = call i32 @free(i8* %26)
%28 = load %struct.params*, %struct.params** %2
%29 = call i32 @free_params(%struct.params* %28)
%30 = load %struct.params*, %struct.params** %3
%31 = call i32 @free_params(%struct.params* %30)
%32 = call i64 @read_func_header(i8** %1, %struct.params** %2, %struct.params** %3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %11
34: ; preds = %17, %0
%35 = call i32 @free(i8* %7)
ret void
}