#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*/ strcpy(char *, char *);
int stringpos(char *, char *);
int strlen(char *);
int stringafterstring(char *s1, char *arg, char *s2) {
  int i, nchar, num;
  char temp[62];
  int pos;
  pos = stringpos(s1, arg);
  nchar = strlen(s1);
  num = 0;
  for (i = pos; i < nchar; i++) {
    temp[num] = s1[i];
    num = num + 1;
  }
  temp[nchar - pos] = '\0';
  strcpy(s2, temp);
  return (0);
}


x86 assembly (clang, -O0):
<stringafterstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <stringpos@plt>
mov    %eax,-0x74(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a6 <stringafterstring+0x76>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <stringafterstring+0x40>
mov    -0x20(%rbp),%eax
sub    -0x74(%rbp),%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringafterstring>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rdi,%r15
call   1060 <stringpos@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
sub    %ebp,%ebx
jle    1181 <stringafterstring+0x41>
movslq %ebp,%rcx
add    %rcx,%r15
not    %ebp
add    %ebp,%eax
add    $0x1,%rax
mov    %rsp,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @stringafterstring(i8* %0, i8* %1, i8* %2) {
%4 = alloca [62 x i8]
%5 = getelementptr inbounds [62 x i8], [62 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @stringpos(i8* %0, i8* %1)
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, %6
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = getelementptr inbounds [62 x i8], [62 x i8]* %4, i64 0, i64 0
%11 = sext i32 %6 to i64
%12 = getelementptr i8, i8* %0, i64 %11
%13 = xor i32 %6, -1
%14 = add i32 %7, %13
%15 = zext i32 %14 to i64
%16 = add nuw nsw i64 %15, 1
br label %17
17: ; preds = %9, %3
%18 = sub nsw i32 %7, %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [62 x i8], [62 x i8]* %4, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @strcpy(i8* %2, i8* %5)
ret i32 0
}