#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int main() {
  int i, j, k = 1;
  char str[20], sub[20];
  printf("Saisir string:");
  gets(str);
  printf("saisir substring:");
  gets(sub);
  for (i = 0; i < strlen(str); i++) {
    if (sub[0] == str[i]) {
      for (j = i + 1; j < strlen(sub) + i; j++) {
        if (str[j] == sub[k]) {
          k++;
        } else {
          k = 0;
          break;
        }
      }
      if (k == strlen(sub)) {
        printf("OK DONE");
        return 0;
      }
    }
  }
  printf("Not Exist");
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <gets@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    1263 <main+0x133>
movsbl -0x50(%rbp),%eax
movslq -0x8(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    1250 <main+0x120>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
add    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1217 <main+0xe7>
movslq -0xc(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
movslq -0x10(%rbp),%rcx
movsbl -0x50(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11f8 <main+0xc8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1204 <main+0xd4>
movl   $0x0,-0x10(%rbp)
jmp    1217 <main+0xe7>
jmp    1209 <main+0xd9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b1 <main+0x81>
mov    -0x10(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
cmp    %ecx,%eax
jne    124b <main+0x11b>
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1276 <main+0x146>
jmp    1250 <main+0x120>
jmp    1255 <main+0x125>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <main+0x47>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0x30(%rsp),%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0xffffffff,%ebx
lea    0xea8(%rip),%rdi
test   %eax,%eax
jle    1256 <main+0x126>
lea    0x11(%rsp),%rbx
mov    $0x1,%r14d
mov    $0x1,%r12d
xor    %r15d,%r15d
lea    0x30(%rsp),%rbp
lea    0x10(%rsp),%r13
jmp    11dd <main+0xad>
xor    %r14d,%r14d
lea    0x10(%rsp),%r13
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    %eax,%r14d
je     124d <main+0x11d>
add    $0x1,%r15
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
add    $0x1,%r12
add    $0x1,%rbx
cmp    %rax,%r15
jge    123f <main+0x10f>
mov    0x30(%rsp),%al
cmp    0x10(%rsp,%r15,1),%al
jne    11c2 <main+0x92>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11b1 <main+0x81>
mov    %r14d,0xc(%rsp)
movslq %r14d,%rax
lea    (%rsp,%rax,1),%r14
add    $0x30,%r14
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r13,1),%eax
cmp    (%r14,%r13,1),%al
jne    11a9 <main+0x79>
mov    %rbp,%rdi
call   1030 <strlen@plt>
add    %r15d,%eax
add    $0x1,%r13
lea    (%r12,%r13,1),%ecx
cmp    %ecx,%eax
jg     1210 <main+0xe0>
mov    0xc(%rsp),%r14d
add    %r13d,%r14d
jmp    11ac <main+0x7c>
lea    0xde3(%rip),%rdi
mov    $0xffffffff,%ebx
jmp    1256 <main+0x126>
xor    %ebx,%ebx
lea    0xdcb(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Saisir string:\00"
@.str.1 = [18 x i8] c"saisir substring:\00"
@.str.2 = [8 x i8] c"OK DONE\00"
@.str.3 = [10 x i8] c"Not Exist\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
store i32 0, i32* %1
store i32 1, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
store i32 0, i32* %2
br label %13
13: ; preds = %67, %0
%14 = load i32, i32* %2
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %70
18: ; preds = %13
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %21, %26
br i1 %27, label %28, label %66
28: ; preds = %18
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %55, %28
%32 = load i32, i32* %3
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = load i32, i32* %2
%36 = add nsw i32 %34, %35
%37 = icmp slt i32 %32, %36
br i1 %37, label %38, label %58
38: ; preds = %31
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %43, %48
br i1 %49, label %50, label %53
50: ; preds = %38
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %54
53: ; preds = %38
store i32 0, i32* %4
br label %58
54: ; preds = %50
br label %55
55: ; preds = %54
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %31
58: ; preds = %53, %31
%59 = load i32, i32* %4
%60 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = icmp eq i32 %59, %61
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %72
65: ; preds = %58
br label %66
66: ; preds = %65, %18
br label %67
67: ; preds = %66
%68 = load i32, i32* %2
%69 = add nsw i32 %68, 1
store i32 %69, i32* %2
br label %13
70: ; preds = %13
%71 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %72
72: ; preds = %70, %63
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [15 x i8] c"Saisir string:\00"
@.str.1 = [18 x i8] c"saisir substring:\00"
@.str.2 = [8 x i8] c"OK DONE\00"
@.str.3 = [10 x i8] c"Not Exist\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strlen(i8* %3)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %53
11: ; preds = %0, %46
%12 = phi i64 [ %48, %46 ], [ 0, %0 ]
%13 = phi i64 [ %52, %46 ], [ 1, %0 ]
%14 = phi i32 [ %47, %46 ], [ 1, %0 ]
%15 = load i8, i8* %4
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %12
%17 = load i8, i8* %16
%18 = icmp eq i8 %15, %17
br i1 %18, label %19, label %46
19: ; preds = %11
%20 = call i32 @strlen(i8* %4)
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %42
22: ; preds = %19
%23 = sext i32 %14 to i64
%24 = trunc i64 %12 to i32
br label %25
25: ; preds = %22, %33
%26 = phi i64 [ %23, %22 ], [ %34, %33 ]
%27 = phi i64 [ %13, %22 ], [ %35, %33 ]
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %26
%31 = load i8, i8* %30
%32 = icmp eq i8 %29, %31
br i1 %32, label %33, label %42
33: ; preds = %25
%34 = add nsw i64 %26, 1
%35 = add nuw nsw i64 %27, 1
%36 = call i32 @strlen(i8* %4)
%37 = add nsw i32 %36, %24
%38 = trunc i64 %35 to i32
%39 = icmp sgt i32 %37, %38
br i1 %39, label %25, label %40
40: ; preds = %33
%41 = trunc i64 %34 to i32
br label %42
42: ; preds = %25, %40, %19
%43 = phi i32 [ %14, %19 ], [ %41, %40 ], [ 0, %25 ]
%44 = call i32 @strlen(i8* %4)
%45 = icmp eq i32 %43, %44
br i1 %45, label %53, label %46
46: ; preds = %11, %42
%47 = phi i32 [ %43, %42 ], [ %14, %11 ]
%48 = add nuw nsw i64 %12, 1
%49 = call i32 @strlen(i8* %3)
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
%52 = add nuw nsw i64 %13, 1
br i1 %51, label %11, label %53
53: ; preds = %46, %42, %0
%54 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %42 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %46 ]
%55 = phi i32 [ -1, %0 ], [ 0, %42 ], [ -1, %46 ]
%56 = call i32 @printf(i8* dereferenceable(1) %54)
ret i32 %55
}