#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 /*<<< orphan*/ abort();
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char, char);
int main(int argc, char **argv) {
  char array1[80];
  char *array2;
  array2 = malloc(80);
  if (!array2) {
    perror(NULL);
    abort();
  }
  for (int i = 0; i < 10; i++) {
    array1[i] = '0' + i;
    array2[i] = '0' + i;
  }
  printf("second elements: '%c' '%c'\n", array1[1], array2[1]);
  printf("40th elements: '%c' '%c'\n", array1[40], array2[40]);
  free(array2);
  while (1) {
    array2 = malloc(1024);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    118f <main+0x3f>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
movl   $0x0,-0x6c(%rbp)
cmpl   $0xa,-0x6c(%rbp)
jge    11d1 <main+0x81>
mov    -0x6c(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x6c(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x6c(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x68(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1196 <main+0x46>
mov    -0x5f(%rbp),%cl
mov    -0x68(%rbp),%rax
lea    0xe21(%rip),%rdi
movsbl %cl,%esi
movsbl 0x1(%rax),%edx
call   1050 <printf@plt>
mov    -0x38(%rbp),%cl
mov    -0x68(%rbp),%rax
lea    0xe23(%rip),%rdi
movsbl %cl,%esi
movsbl 0x28(%rax),%edx
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,-0x68(%rbp)
jmp    120e <main+0xbe>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x50,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11b2 <main+0x62>
mov    %rax,%rbx
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,(%rbx)
movw   $0x3938,0x8(%rbx)
lea    0xe83(%rip),%rdi
mov    $0x31,%esi
mov    $0x31,%edx
call   1050 <printf@plt>
lea    0xe89(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
jmp    11b0 <main+0x60>
xor    %edi,%edi
call   1070 <perror@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"second elements: '%c' '%c'\0A\00"
@.str.1 = [26 x i8] c"40th elements: '%c' '%c'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @malloc(i32 80)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = call i32 @perror(i32* null)
%14 = call i32 (...) @abort()
unreachable
15: ; preds = %2
store i32 0, i32* %8
br label %16
16: ; preds = %33, %15
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %36
19: ; preds = %16
%20 = load i32, i32* %8
%21 = add nsw i32 48, %20
%22 = trunc i32 %21 to i8
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %8
%27 = add nsw i32 48, %26
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
br label %33
33: ; preds = %19
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %16
36: ; preds = %16
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 1
%38 = load i8, i8* %37
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = load i8, i8* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 signext %38, i8 signext %41)
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 40
%44 = load i8, i8* %43
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i64 40
%47 = load i8, i8* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8 signext %44, i8 signext %47)
%49 = load i8*, i8** %7
%50 = call i32 @free(i8* %49)
br label %51
51: ; preds = %36, %51
%52 = call i8* @malloc(i32 1024)
store i8* %52, i8** %7
br label %51
}

LLVM IR (-O2):
@.str = [28 x i8] c"second elements: '%c' '%c'\0A\00"
@.str.1 = [26 x i8] c"40th elements: '%c' '%c'\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2
store i8 48, i8* %3
%6 = getelementptr inbounds i8, i8* %3, i64 1
store i8 49, i8* %6
%7 = getelementptr inbounds i8, i8* %3, i64 2
store i8 50, i8* %7
%8 = getelementptr inbounds i8, i8* %3, i64 3
store i8 51, i8* %8
%9 = getelementptr inbounds i8, i8* %3, i64 4
store i8 52, i8* %9
%10 = getelementptr inbounds i8, i8* %3, i64 5
store i8 53, i8* %10
%11 = getelementptr inbounds i8, i8* %3, i64 6
store i8 54, i8* %11
%12 = getelementptr inbounds i8, i8* %3, i64 7
store i8 55, i8* %12
%13 = getelementptr inbounds i8, i8* %3, i64 8
store i8 56, i8* %13
%14 = getelementptr inbounds i8, i8* %3, i64 9
store i8 57, i8* %14
%15 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 signext 49, i8 signext 49)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8 signext undef, i8 signext undef)
%17 = tail call i32 @free(i8* %3)
br label %21
18: ; preds = %2
%19 = tail call i32 @perror(i32* null)
%20 = tail call i32 (...) @abort()
unreachable
21: ; preds = %21, %5
br label %21
}