#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 atoi(char *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int max_seq(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char **argv) {
  int nthreads, nelt, i, t, maxv_seq, maxv_mt;
  int *tab;
  nelt = atoi(argv[1]);
  nthreads = atoi(argv[2]);
  tab = (int *)malloc(nelt * sizeof(int));
  srand(nelt);
  for (i = 0; i < nelt; i++) {
    tab[i] = 1 + (rand() % 1000);
  }
  maxv_mt = 0;
  maxv_seq = max_seq(tab, nelt);
  if (maxv_seq == maxv_mt) {
    printf("PASSED\n");
  } else {
    printf("FAILED\n");
    printf("Valeur correcte : %d\n", maxv_seq);
    printf("Votre valeur    : %d\n", maxv_mt);
  }
  free(tab);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <srand@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ff <main+0x8f>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0x58>
movl   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1050 <max_seq@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1234 <main+0xc4>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1264 <main+0xf4>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
call   1070 <srand@plt>
test   %r14d,%r14d
jle    11f7 <main+0x77>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <main+0x40>
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <max_seq@plt>
test   %eax,%eax
je     1236 <main+0xb6>
mov    %eax,%ebp
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xde5(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdeb(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1242 <main+0xc2>
lea    0xdf6(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PASSED\0A\00"
@.str.1 = [8 x i8] c"FAILED\0A\00"
@.str.2 = [22 x i8] c"Valeur correcte : %d\0A\00"
@.str.3 = [22 x i8] c"Votre valeur : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %12
%27 = load i32, i32* %7
%28 = call i32 @srand(i32 %27)
store i32 0, i32* %8
br label %29
29: ; preds = %41, %2
%30 = load i32, i32* %8
%31 = load i32, i32* %7
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = call i32 (...) @rand()
%35 = srem i32 %34, 1000
%36 = add nsw i32 1, %35
%37 = load i32*, i32** %12
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
store i32 %36, i32* %40
br label %41
41: ; preds = %33
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %29
44: ; preds = %29
store i32 0, i32* %11
%45 = load i32*, i32** %12
%46 = load i32, i32* %7
%47 = call i32 @max_seq(i32* %45, i32 %46)
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = load i32, i32* %11
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %44
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %59
53: ; preds = %44
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%55 = load i32, i32* %10
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %11
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %53, %51
%60 = load i32*, i32** %12
%61 = call i32 @free(i32* %60)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [22 x i8] c"Valeur correcte : %d\0A\00"
@.str.3 = [22 x i8] c"Votre valeur : %d\0A\00"
@str = [7 x i8] c"FAILED\00"
@str.4 = [7 x i8] c"PASSED\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = shl i32 %5, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = tail call i32 @srand(i32 %5)
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = zext i32 %5 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %19, %13 ]
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 1000
%17 = add nsw i32 %16, 1
%18 = getelementptr inbounds i32, i32* %8, i64 %14
store i32 %17, i32* %18
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %2
%22 = tail call i32 @max_seq(i32* %8, i32 %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.4, i64 0, i64 0))
br label %30
26: ; preds = %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %30
30: ; preds = %26, %24
%31 = tail call i32 @free(i32* %8)
ret i32 0
}