#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*/ a;

/* Variables and functions */
double RAND_MAX;
double *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int strlen(char *);
int main() {
  char a[10] = "Jim";
  printf("a = %s\n", a);
  printf("size of a = %zu\n", sizeof(a) / sizeof(char));
  printf("strlen(a) = %zu\n", strlen(a));
  for (int i = 0; i < (strlen(a) + 1); i++) {
    if (a[i] == '\0')
      printf("End of string\n");
    else
      printf("%c\n", a[i]);
  }
  double *pArray = NULL;
  int i = 0;
  pArray = malloc(100 * sizeof(double));
  if (pArray != NULL) {
    for (i = 0; i < 100; i++) {
      pArray[i] = (double)rand() / RAND_MAX;
      printf("pArray[%d]=%.5f\n", i, pArray[i]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xe(%rbp),%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0xe(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1218 <main+0xd8>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11ee <main+0xae>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1205 <main+0xc5>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120a <main+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11aa <main+0x6a>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x320,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12a6 <main+0x166>
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    12a1 <main+0x161>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d84(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdbb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1247 <main+0x107>
jmp    12a6 <main+0x166>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x0,0x10(%rsp)
movq   $0x6d694a,0x8(%rsp)
lea    0xe98(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     1210 <main+0xc0>
mov    $0xffffffffffffffff,%rbx
lea    0xe83(%rip),%r14
lea    0x8(%rsp),%r12
lea    0xe62(%rip),%r15
jmp    11fd <main+0xad>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
add    $0x1,%rbx
cmp    %rax,%rbx
jge    1210 <main+0xc0>
movsbl 0x9(%rsp,%rbx,1),%esi
test   %esi,%esi
jne    11e0 <main+0x90>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    11ea <main+0x9a>
mov    $0x320,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1271 <main+0x121>
mov    %rax,%r15
mov    0x2dbf(%rip),%r12
lea    0xe08(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r12),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1240 <main+0xf0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [10 x i8] c"Jim\00\00\00\00\00\00\00"
@.str = [8 x i8] c"a = %s\0A\00"
@.str.1 = [17 x i8] c"size of a = %zu\0A\00"
@.str.2 = [17 x i8] c"strlen(a) = %zu\0A\00"
@.str.3 = [15 x i8] c"End of string\0A\00"
@.str.4 = [4 x i8] c"%c\0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.5 = [17 x i8] c"pArray[%d]=%.5f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i8]* %2 to i8*
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 10)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %36, %0
%14 = load i32, i32* %3
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
%18 = icmp slt i32 %14, %17
br i1 %18, label %19, label %39
19: ; preds = %13
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %35
28: ; preds = %19
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28, %26
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %13
39: ; preds = %13
store double* null, double** %4
store i32 0, i32* %5
%40 = call double* @malloc(i32 800)
store double* %40, double** %4
%41 = load double*, double** %4
%42 = icmp ne double* %41, null
br i1 %42, label %43, label %67
43: ; preds = %39
store i32 0, i32* %5
br label %44
44: ; preds = %63, %43
%45 = load i32, i32* %5
%46 = icmp slt i32 %45, 100
br i1 %46, label %47, label %66
47: ; preds = %44
%48 = call i64 (...) @rand()
%49 = sitofp i64 %48 to double
%50 = load double, double* @RAND_MAX
%51 = fdiv double %49, %50
%52 = load double*, double** %4
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
store double %51, double* %55
%56 = load i32, i32* %5
%57 = load double*, double** %4
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %56, double %61)
br label %63
63: ; preds = %47
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %44
66: ; preds = %44
br label %67
67: ; preds = %66, %39
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@__const.main.a = [10 x i8] c"Jim\00\00\00\00\00\00\00"
@.str = [8 x i8] c"a = %s\0A\00"
@.str.1 = [17 x i8] c"size of a = %zu\0A\00"
@.str.2 = [17 x i8] c"strlen(a) = %zu\0A\00"
@.str.4 = [4 x i8] c"%c\0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.5 = [17 x i8] c"pArray[%d]=%.5f\0A\00"
@str = [14 x i8] c"End of string\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 10)
%5 = call i32 @strlen(i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 @strlen(i8* %2)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %22, %0
%10 = call double* @malloc(i32 800)
%11 = icmp eq double* %10, null
br i1 %11, label %38, label %27
12: ; preds = %0, %22
%13 = phi i64 [ %23, %22 ], [ 0, %0 ]
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %22
19: ; preds = %12
%20 = sext i8 %15 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %17, %19
%23 = add nuw nsw i64 %13, 1
%24 = call i32 @strlen(i8* %2)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %13, %25
br i1 %26, label %12, label %9
27: ; preds = %9, %27
%28 = phi i64 [ %36, %27 ], [ 0, %9 ]
%29 = call i64 (...) @rand()
%30 = sitofp i64 %29 to double
%31 = load double, double* @RAND_MAX
%32 = fdiv double %30, %31
%33 = getelementptr inbounds double, double* %10, i64 %28
store double %32, double* %33
%34 = trunc i64 %28 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %34, double %32)
%36 = add nuw nsw i64 %28, 1
%37 = icmp eq i64 %36, 100
br i1 %37, label %38, label %27
38: ; preds = %27, %9
ret i32 0
}