#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 *);
void strretic(char chaine[], int ic, char chaineR[]) {
  int i;
  char c;
  char rc[1000];
  c = 1;
  for (i = 0; i < ic; i++)
    rc[i] = chaine[i];
  rc[i] = '\0';
  strcpy(chaineR, rc);
}


x86 assembly (clang, -O0):
<strretic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x1,-0x1d(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1161 <strretic+0x51>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <strretic+0x21>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strretic>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rdx,%r14
test   %esi,%esi
jle    1146 <strretic+0x26>
mov    %rdi,%rax
mov    %esi,%ebx
mov    %rsp,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
jmp    1148 <strretic+0x28>
xor    %ebx,%ebx
movb   $0x0,(%rsp,%rbx,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @strretic(i8* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = zext i32 %1 to i64
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %7, %3
%12 = phi i64 [ 0, %3 ], [ %10, %7 ]
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %12
store i8 0, i8* %13
%14 = call i32 @strcpy(i8* %2, i8* %5)
ret void
}