#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 alea(int, int);
int /*<<< orphan*/ aleainit();
int decoupe(char *, char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *message(char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char **argv) {
  char emeteur[255], type[255], valeur[255];
  int decoupeOk;
  aleainit();
  sprintf(valeur, "%d", alea(1, 50000));
  printf("Demande de paiement de %s euros\n", valeur);
  char *msg = message("0001000000000000", "Demande", valeur);
  printf("Le message est : *%s*\n", msg);
  decoupeOk = decoupe(msg, emeteur, type, valeur);
  if (!decoupeOk) {
    printf("Erreur de découpage!!\n");
    exit(0);
  }
  printf("La carte bacaire est : %s\n", emeteur);
  printf("Le type du message est : %s\n", type);
  printf("La valeur est : %s\n", valeur);
  printf("\n\nMaintenant, on coupe le message pour avoir une erreur.\n");
  msg[5] = '\0';
  printf("message = %s\n", msg);
  decoupeOk = decoupe(msg, emeteur, type, valeur);
  if (!decoupeOk) {
    printf("Erreur de découpage!!\n");
    perror("TestMessage (decoupe)");
    exit(0);
  }
  free(msg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <aleainit@plt>
lea    -0x310(%rbp),%rax
mov    %rax,-0x328(%rbp)
mov    $0x1,%edi
mov    $0xc350,%esi
call   1050 <alea@plt>
mov    -0x328(%rbp),%rdi
mov    %eax,%edx
lea    0xe23(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x310(%rbp),%rsi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x310(%rbp),%rdx
lea    0xe1f(%rip),%rdi
lea    0xe29(%rip),%rsi
call   1040 <message@plt>
mov    %rax,-0x320(%rbp)
mov    -0x320(%rbp),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x320(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x310(%rbp),%rcx
call   1060 <decoupe@plt>
mov    %eax,-0x314(%rbp)
cmpl   $0x0,-0x314(%rbp)
jne    1276 <main+0xe6>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    -0x110(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x310(%rbp),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x320(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x320(%rbp),%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x320(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x310(%rbp),%rcx
call   1060 <decoupe@plt>
mov    %eax,-0x314(%rbp)
cmpl   $0x0,-0x314(%rbp)
jne    1338 <main+0x1a8>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdd4(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x320(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x308,%rsp
xor    %eax,%eax
call   10a0 <aleainit@plt>
mov    $0x1,%edi
mov    $0xc350,%esi
call   1060 <alea@plt>
lea    0xe35(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %eax,%edx
call   10b0 <sprintf@plt>
lea    0xe24(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe34(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    %r14,%rdx
call   1040 <message@plt>
mov    %rax,%rbx
lea    0xe34(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x200(%rsp),%rsi
lea    0x100(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1070 <decoupe@plt>
test   %eax,%eax
je     12cb <main+0x12b>
lea    0xe17(%rip),%rdi
lea    0x200(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe19(%rip),%rdi
lea    0x100(%rsp),%r15
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    %rsp,%r12
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe41(%rip),%rdi
call   1050 <puts@plt>
movb   $0x0,0x5(%rbx)
lea    0xe0d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1070 <decoupe@plt>
test   %eax,%eax
je     12de <main+0x13e>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x308,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe2b(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0xe18(%rip),%rdi
call   1050 <puts@plt>
lea    0xdbd(%rip),%rdi
call   1090 <perror@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [33 x i8] c"Demande de paiement de %s euros\0A\00"
@.str.2 = [17 x i8] c"0001000000000000\00"
@.str.3 = [8 x i8] c"Demande\00"
@.str.4 = [23 x i8] c"Le message est : *%s*\0A\00"
@.str.5 = [24 x i8] c"Erreur de d\C3\A9coupage!!\0A\00"
@.str.6 = [27 x i8] c"La carte bacaire est : %s\0A\00"
@.str.7 = [29 x i8] c"Le type du message est : %s\0A\00"
@.str.8 = [20 x i8] c"La valeur est : %s\0A\00"
@.str.9 = [58 x i8] c"\0A\0AMaintenant, on coupe le message pour avoir une erreur.\0A\00"
@.str.10 = [14 x i8] c"message = %s\0A\00"
@.str.11 = [22 x i8] c"TestMessage (decoupe)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @aleainit()
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%13 = call i32 @alea(i32 1, i32 50000)
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%18 = call i8* @message(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %17)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %10
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%25 = call i32 @decoupe(i8* %21, i8* %22, i8* %23, i8* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %2
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0))
%39 = load i8*, i8** %10
%40 = getelementptr inbounds i8, i8* %39, i64 5
store i8 0, i8* %40
%41 = load i8*, i8** %10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %10
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%47 = call i32 @decoupe(i8* %43, i8* %44, i8* %45, i8* %46)
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %31
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 @exit(i32 0)
unreachable
54: ; preds = %31
%55 = load i8*, i8** %10
%56 = call i32 @free(i8* %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [33 x i8] c"Demande de paiement de %s euros\0A\00"
@.str.2 = [17 x i8] c"0001000000000000\00"
@.str.3 = [8 x i8] c"Demande\00"
@.str.4 = [23 x i8] c"Le message est : *%s*\0A\00"
@.str.6 = [27 x i8] c"La carte bacaire est : %s\0A\00"
@.str.7 = [29 x i8] c"Le type du message est : %s\0A\00"
@.str.8 = [20 x i8] c"La valeur est : %s\0A\00"
@.str.10 = [14 x i8] c"message = %s\0A\00"
@.str.11 = [22 x i8] c"TestMessage (decoupe)\00"
@str.12 = [57 x i8] c"\0A\0AMaintenant, on coupe le message pour avoir une erreur.\00"
@str.13 = [23 x i8] c"Erreur de d\C3\A9coupage!!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%9 = tail call i32 (...) @aleainit()
%10 = tail call i32 @alea(i32 1, i32 50000)
%11 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = call i8* @message(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = call i32 @decoupe(i8* %13, i8* %6, i8* %7, i8* %8)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.12, i64 0, i64 0))
%25 = getelementptr inbounds i8, i8* %13, i64 5
store i8 0, i8* %25
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %13)
%27 = call i32 @decoupe(i8* %13, i8* %6, i8* %7, i8* %8)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %20
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%31 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %20
%34 = call i32 @free(i8* %13)
ret i32 0
}