#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 Emission(char *);
int longueur_fichier(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int envoyerReponse200JPG(char *nomFichier) {
  char req[500];
  char len[2];
  int lenght = 0;
  lenght = longueur_fichier(nomFichier);
  sprintf(len, "%d", lenght);
  strcpy(req,
         "\nHTTP/1.1 200 OK\r\nContent-type: image/jpeg\r\nContent-length: ");
  strcat(req, len);
  strcat(req, "\n\n");
  if (Emission(req) != 1) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x218(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <longueur_fichier@plt>
mov    %eax,-0x218(%rbp)
lea    -0x212(%rbp),%rdi
mov    -0x218(%rbp),%edx
lea    0xe74(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
lea    -0x212(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
call   1050 <Emission@plt>
cmp    $0x1,%eax
je     11eb <envoyerReponse200JPG+0x9b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <envoyerReponse200JPG+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
sub    $0x208,%rsp
call   1040 <longueur_fichier@plt>
lea    0xe9a(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
lea    0xe87(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1050 <Emission@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
neg    %ecx
mov    %ecx,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [61 x i8] c"\0AHTTP/1.1 200 OK\0D\0AContent-type: image/jpeg\0D\0AContent-length: \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i32 @envoyerReponse200JPG(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [500 x i8]
%5 = alloca [2 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = call i32 @longueur_fichier(i8* %7)
store i32 %8, i32* %6
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* %6
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%20 = call i32 @Emission(i8* %19)
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %23
22: ; preds = %1
store i32 -1, i32* %2
br label %24
23: ; preds = %1
store i32 0, i32* %2
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [61 x i8] c"\0AHTTP/1.1 200 OK\0D\0AContent-type: image/jpeg\0D\0AContent-length: \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i32 @envoyerReponse200JPG(i8* %0) {
%2 = alloca [500 x i8]
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @longueur_fichier(i8* %0)
%7 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strcat(i8* %4, i8* %5)
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @Emission(i8* %4)
%12 = icmp ne i32 %11, 1
%13 = sext i1 %12 to i32
ret i32 %13
}