#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
void addcontect(FILE *des, char *src) {
  FILE *f1;
  char ch;
  if ((f1 = fopen(src, "r")) == NULL) {
    printf("\nerror occurred when opening the src file to combine peaks!");
    getchar();
    exit(1);
  }
  ch = fgetc(f1);
  while (!feof(f1)) {
    fputc(ch, des);
    ch = fgetc(f1);
  }
  fclose(f1);
}


x86 assembly (clang, -O0):
<addcontect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11cb <addcontect+0x4b>
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f5 <addcontect+0x75>
jmp    1215 <addcontect+0x95>
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    11d7 <addcontect+0x57>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addcontect>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe6e(%rip),%rsi
mov    %rax,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11e0 <addcontect+0x60>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11d3 <addcontect+0x53>
movsbl %bl,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
jmp    11b0 <addcontect+0x30>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [60 x i8] c"\0Aerror occurred when opening the src file to combine peaks!\00"
define void @addcontect(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @getchar()
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i32*, i32** %5
%16 = call signext i8 @fgetc(i32* %15)
store i8 %16, i8* %6
br label %17
17: ; preds = %22, %14
%18 = load i32*, i32** %5
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8, i8* %6
%24 = load i32*, i32** %3
%25 = call i32 @fputc(i8 signext %23, i32* %24)
%26 = load i32*, i32** %5
%27 = call signext i8 @fgetc(i32* %26)
store i8 %27, i8* %6
br label %17
28: ; preds = %17
%29 = load i32*, i32** %5
%30 = call i32 @fclose(i32* %29)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [60 x i8] c"\0Aerror occurred when opening the src file to combine peaks!\00"
define void @addcontect(i32* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @getchar()
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call signext i8 @fgetc(i32* %3)
%11 = tail call i32 @feof(i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9, %13
%14 = phi i8 [ %16, %13 ], [ %10, %9 ]
%15 = tail call i32 @fputc(i8 signext %14, i32* %0)
%16 = tail call signext i8 @fgetc(i32* %3)
%17 = tail call i32 @feof(i32* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %13, %9
%20 = tail call i32 @fclose(i32* %3)
ret void
}