#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 *my_calloc(int, int);
int strlen(char const *);
char *pickup_str(const char *str, const int st) {
  int i;
  int len = strlen(str);
  char *strtemp = my_calloc(len, sizeof(char));
  for (i = 0;; i++) {
    strtemp[i] = str[i + st];
    if (str[i + st] == '\0')
      break;
  }
  return strtemp;
}


x86 assembly (clang, -O0):
<pickup_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1030 <my_calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    118d <pickup_str+0x6d>
jmp    11a0 <pickup_str+0x80>
jmp    1192 <pickup_str+0x72>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <pickup_str+0x33>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pickup_str>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <my_calloc@plt>
movslq %ebp,%rcx
add    %rbx,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rcx,%rdx,1),%ebx
mov    %bl,(%rax,%rdx,1)
cmpb   $0x0,(%rcx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1150 <pickup_str+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @pickup_str(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i8* @my_calloc(i32 %3, i32 1)
%5 = sext i32 %1 to i64
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ %14, %6 ], [ 0, %2 ]
%8 = add nsw i64 %7, %5
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %4, i64 %7
store i8 %10, i8* %11
%12 = load i8, i8* %9
%13 = icmp eq i8 %12, 0
%14 = add nuw i64 %7, 1
br i1 %13, label %15, label %6
15: ; preds = %6
ret i8* %4
}