#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 */
scalar_t__ malloc(int);
void obtain_list(int n, int *l, char **s) {
  int i;
  int c;
  if (n < 0)
    n = 0;
  *l = n;
  *s = (char *)malloc(*l);
  for (i = 0; i < *l; i++) {
    (*s)[i] = i;
  }
}


x86 assembly (clang, -O0):
<obtain_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1134 <obtain_list+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1189 <obtain_list+0x79>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <obtain_list+0x49>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obtain_list>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %eax,%eax
test   %edi,%edi
cmovs  %eax,%edi
mov    %edi,(%rsi)
call   1030 <malloc@plt>
mov    %rax,(%r14)
cmpl   $0x0,(%rbx)
jle    1152 <obtain_list+0x42>
movb   $0x0,(%rax)
cmpl   $0x2,(%rbx)
jl     1152 <obtain_list+0x42>
mov    $0x1,%eax
nopl   (%rax)
mov    (%r14),%rcx
mov    %al,(%rcx,%rax,1)
add    $0x1,%rax
movslq (%rbx),%rcx
cmp    %rcx,%rax
jl     1140 <obtain_list+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @obtain_list(i32 %0, i32* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8** %2, i8*** %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 0, i32* %4
br label %12
12: ; preds = %11, %3
%13 = load i32, i32* %4
%14 = load i32*, i32** %5
store i32 %13, i32* %14
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
%19 = load i8**, i8*** %6
store i8* %18, i8** %19
store i32 0, i32* %7
br label %20
20: ; preds = %33, %12
%21 = load i32, i32* %7
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %36
25: ; preds = %20
%26 = load i32, i32* %7
%27 = trunc i32 %26 to i8
%28 = load i8**, i8*** %6
%29 = load i8*, i8** %28
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %27, i8* %32
br label %33
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %20
36: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @obtain_list(i32 %0, i32* nocapture %1, i8** nocapture %2) {
%4 = icmp sgt i32 %0, 0
%5 = select i1 %4, i32 %0, i32 0
store i32 %5, i32* %1
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %2
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %3
store i8 0, i8* %7
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %22
13: ; preds = %10, %13
%14 = phi i64 [ %18, %13 ], [ 1, %10 ]
%15 = load i8*, i8** %2
%16 = trunc i64 %14 to i8
%17 = getelementptr inbounds i8, i8* %15, i64 %14
store i8 %16, i8* %17
%18 = add nuw nsw i64 %14, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %13, label %22
22: ; preds = %13, %10, %3
ret void
}