#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 */
char *astrcpy(char const *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
scalar_t__ mu__malloc(char *, int, size_t);
size_t strlen(char const *);
char *astrleft(const char *src, size_t count) {
  char *leftString = NULL;
  size_t actualCount;
  if (count == 0) {
    return astrcpy("");
  } else if (count >= strlen(src)) {
    return astrcpy(src);
  } else {
    leftString = (char *)mu__malloc(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/astring.c",
        76, (count + 1) * sizeof(char));
    if (count >= strlen(src)) {
      actualCount = strlen(src);
    } else {
      actualCount = count;
    }
    memcpy(leftString, src, actualCount);
    leftString[actualCount] = '\0';
  }
  return leftString;
}


x86 assembly (clang, -O0):
<astrleft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1178 <astrleft+0x38>
lea    0xf1b(%rip),%rdi
call   1040 <astrcpy@plt>
mov    %rax,-0x8(%rbp)
jmp    1231 <astrleft+0xf1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jb     11ab <astrleft+0x6b>
mov    -0x10(%rbp),%rdi
call   1040 <astrcpy@plt>
mov    %rax,-0x8(%rbp)
jmp    1231 <astrleft+0xf1>
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
shl    $0x0,%rdx
lea    0xe42(%rip),%rdi
mov    $0x4c,%esi
call   1060 <mu__malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jb     11ff <astrleft+0xbf>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
jmp    1207 <astrleft+0xc7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1229 <astrleft+0xe9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astrleft>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11a9 <astrleft+0x69>
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    %rbx,%rax
jbe    11b2 <astrleft+0x72>
lea    0x1(%rbx),%rdx
lea    0xe98(%rip),%rdi
mov    $0x4c,%esi
call   1060 <mu__malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
cmp    %rbx,%rax
cmova  %rbx,%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
movb   $0x0,(%r15,%r12,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xed5(%rip),%rdi
jmp    11b5 <astrleft+0x75>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <astrcpy@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/astring.c\00"
define i8* @astrleft(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* null, i8** %6
%8 = load i64, i64* %5
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i8* @astrcpy(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %3
br label %46
12: ; preds = %2
%13 = load i64, i64* %5
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = icmp uge i64 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = call i8* @astrcpy(i8* %18)
store i8* %19, i8** %3
br label %46
20: ; preds = %12
%21 = load i64, i64* %5
%22 = add i64 %21, 1
%23 = mul i64 %22, 1
%24 = call i64 @mu__malloc(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0), i32 76, i64 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %6
%26 = load i64, i64* %5
%27 = load i8*, i8** %4
%28 = call i64 @strlen(i8* %27)
%29 = icmp uge i64 %26, %28
br i1 %29, label %30, label %33
30: ; preds = %20
%31 = load i8*, i8** %4
%32 = call i64 @strlen(i8* %31)
store i64 %32, i64* %7
br label %35
33: ; preds = %20
%34 = load i64, i64* %5
store i64 %34, i64* %7
br label %35
35: ; preds = %33, %30
%36 = load i8*, i8** %6
%37 = load i8*, i8** %4
%38 = load i64, i64* %7
%39 = call i32 @memcpy(i8* %36, i8* %37, i64 %38)
%40 = load i8*, i8** %6
%41 = load i64, i64* %7
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8 0, i8* %42
br label %43
43: ; preds = %35
br label %44
44: ; preds = %43
%45 = load i8*, i8** %6
store i8* %45, i8** %3
br label %46
46: ; preds = %44, %17, %10
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/astring.c\00"
define i8* @astrleft(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i8* @astrcpy(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %20
6: ; preds = %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = icmp ugt i64 %7, %1
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i8* @astrcpy(i8* %0)
br label %20
11: ; preds = %6
%12 = add nuw i64 %1, 1
%13 = tail call i64 @mu__malloc(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0), i32 76, i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%16 = icmp ugt i64 %15, %1
%17 = select i1 %16, i64 %1, i64 %15
%18 = tail call i32 @memcpy(i8* %14, i8* %0, i64 %17)
%19 = getelementptr inbounds i8, i8* %14, i64 %17
store i8 0, i8* %19
br label %20
20: ; preds = %11, %9, %4
%21 = phi i8* [ %5, %4 ], [ %10, %9 ], [ %14, %11 ]
ret i8* %21
}