#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*/ printf(char *, char *, char *);
int /*<<< orphan*/ substr(char *, char *, int, int);
int main() {
  char s1[50] = "qwertyuioplkjhgfdsaxcvbnmz";
  char s2[50];
  printf("%s\n%s\n", s1, s2);
  substr(s2, s1, 10, 32);
  printf("%s\n%s\n", s1, s2);
  substr(s2, s1, 10, 10);
  printf("%s\n%s\n", s1, s2);
  substr(s2, s1, 10, -1);
  printf("%s\n%s\n", s1, s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x32,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
mov    $0x20,%ecx
call   1030 <substr@plt>
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%ecx
mov    %ecx,%edx
call   1030 <substr@plt>
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1030 <substr@plt>
lea    -0x40(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
movaps 0xeed(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
lea    0xed5(%rip),%r14
mov    %rsp,%rbx
lea    0x40(%rsp),%r15
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0x20,%ecx
call   1030 <substr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0xa,%ecx
call   1030 <substr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1030 <substr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s1 = [50 x i8] c"qwertyuioplkjhgfdsaxcvbnmz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"%s\0A%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
store i32 0, i32* %1
%4 = bitcast [50 x i8]* %2 to i8*
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%10 = call i32 @substr(i8* %8, i8* %9, i32 10, i32 32)
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 @substr(i8* %14, i8* %15, i32 10, i32 10)
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%22 = call i32 @substr(i8* %20, i8* %21, i32 10, i32 -1)
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [50 x i8] c"qwertyuioplkjhgfdsaxcvbnmz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"%s\0A%s\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = call i32 @substr(i8* %4, i8* %3, i32 10, i32 32)
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%8 = call i32 @substr(i8* %4, i8* %3, i32 10, i32 10)
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%10 = call i32 @substr(i8* %4, i8* %3, i32 10, i32 -1)
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
ret i32 0
}