#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int corpsMessage(char *nomFichierSource, char *nomFichierCorps) {
  int numero = 0;
  int i;
  long longueurFichier = 0;
  char ligne1[300];
  FILE *fichier1 = NULL;
  fichier1 = fopen(nomFichierSource, "r+");
  fseek(fichier1, 0, SEEK_END);
  longueurFichier = ftell(fichier1);
  rewind(fichier1);
  FILE *fichier2 = NULL;
  fichier2 = fopen(nomFichierCorps, "w+");
  while (fgets(ligne1, 300, fichier1) != NULL) {
    if (strcmp(ligne1, "\n") == 0) {
      while (fgets(ligne1, 300, fichier1) != NULL)
        fputs(ligne1, fichier2);
    }
  }
  fclose(fichier1);
  fclose(fichier2);
  return 0;
}


x86 assembly (clang, -O0):
<corpsMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x158(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rdi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x158(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x158(%rbp),%rdi
call   1040 <rewind@plt>
movq   $0x0,-0x160(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x160(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x158(%rbp),%rdx
mov    $0x12c,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12a1 <corpsMessage+0x121>
lea    -0x150(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    129c <corpsMessage+0x11c>
jmp    125d <corpsMessage+0xdd>
lea    -0x150(%rbp),%rdi
mov    -0x158(%rbp),%rdx
mov    $0x12c,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1297 <corpsMessage+0x117>
lea    -0x150(%rbp),%rdi
mov    -0x160(%rbp),%rsi
call   1050 <fputs@plt>
jmp    125d <corpsMessage+0xdd>
jmp    129c <corpsMessage+0x11c>
jmp    1219 <corpsMessage+0x99>
mov    -0x158(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x160(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corpsMessage>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %rsi,%rbx
lea    0xe68(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %r14,%rdi
call   1040 <rewind@plt>
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x12c,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1252 <corpsMessage+0xd2>
lea    0xe15(%rip),%r15
mov    %rsp,%rbx
jmp    1215 <corpsMessage+0x95>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1252 <corpsMessage+0xd2>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1200 <corpsMessage+0x80>
jmp    123b <corpsMessage+0xbb>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1230 <corpsMessage+0xb0>
jmp    1200 <corpsMessage+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@SEEK_END = global i32 0
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @corpsMessage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca [300 x i8]
%9 = alloca i32*
%10 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i64 0, i64* %7
store i32* null, i32** %9
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = load i32, i32* @SEEK_END
%15 = call i32 @fseek(i32* %13, i32 0, i32 %14)
%16 = load i32*, i32** %9
%17 = call i64 @ftell(i32* %16)
store i64 %17, i64* %7
%18 = load i32*, i32** %9
%19 = call i32 @rewind(i32* %18)
store i32* null, i32** %10
%20 = load i8*, i8** %4
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %10
br label %22
22: ; preds = %42, %2
%23 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%24 = load i32*, i32** %9
%25 = call i32* @fgets(i8* %23, i32 300, i32* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %43
27: ; preds = %22
%28 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %27
br label %32
32: ; preds = %37, %31
%33 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%34 = load i32*, i32** %9
%35 = call i32* @fgets(i8* %33, i32 300, i32* %34)
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%39 = load i32*, i32** %10
%40 = call i32 @fputs(i8* %38, i32* %39)
br label %32
41: ; preds = %32
br label %42
42: ; preds = %41, %27
br label %22
43: ; preds = %22
%44 = load i32*, i32** %9
%45 = call i32 @fclose(i32* %44)
%46 = load i32*, i32** %10
%47 = call i32 @fclose(i32* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@SEEK_END = global i32 0
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @corpsMessage(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [300 x i8]
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %5, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %5)
%9 = tail call i32 @rewind(i32* %5)
%10 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32* @fgets(i8* %4, i32 300, i32* %5)
%12 = icmp eq i32* %11, null
br i1 %12, label %26, label %13
13: ; preds = %2, %23
%14 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i32* @fgets(i8* %4, i32 300, i32* %5)
%18 = icmp eq i32* %17, null
br i1 %18, label %23, label %19
19: ; preds = %16, %19
%20 = call i32 @fputs(i8* %4, i32* %10)
%21 = call i32* @fgets(i8* %4, i32 300, i32* %5)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %19
23: ; preds = %19, %16, %13
%24 = call i32* @fgets(i8* %4, i32 300, i32* %5)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %13
26: ; preds = %23, %2
%27 = call i32 @fclose(i32* %5)
%28 = call i32 @fclose(i32* %10)
ret i32 0
}