#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 *gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  printf("Introduceti numele intreg: \n");
  char string[100];
  char *ret = gets(string);
  if (ret == NULL) {
    printf("S-a inregistrat o eroare \n");
    return -1;
  }
  printf("Numele este: \n %s \n", string);
  int c;
  for (c = 0; c < 100; c++) {
    if (string[c] == '\0') {
      break;
    } else {
      printf("%c ", string[c]);
    }
  }
  for (c = 0; c < 100; c++) {
    if (string[c] == '\0') {
      break;
    }
  }
  int len = strlen(string);
  printf("my len=%i strlen=%i \n", c, strlen(string));
  int flag = 3;
  for (c = 0; c < strlen(string); c++) {
    if (string[c] == 'c') {
      flag = 7;
      break;
    }
  }
  if (flag == 7) {
    printf("Am gasit caracterul, este pe pozitia %i \n", c);
  } else {
    printf("Nu exista, sorry \n");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    1182 <main+0x52>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1302 <main+0x1d2>
lea    -0x70(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x64,-0x7c(%rbp)
jge    11e6 <main+0xb6>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11bc <main+0x8c>
jmp    11e6 <main+0xb6>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d8 <main+0xa8>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    119b <main+0x6b>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x64,-0x7c(%rbp)
jge    1221 <main+0xf1>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    120e <main+0xde>
jmp    1221 <main+0xf1>
jmp    1213 <main+0xe3>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11ed <main+0xbd>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x80(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x88(%rbp),%esi
mov    %eax,%edx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x84(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    12bc <main+0x18c>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x63,%eax
jne    12a9 <main+0x179>
movl   $0x7,-0x84(%rbp)
jmp    12bc <main+0x18c>
jmp    12ae <main+0x17e>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1266 <main+0x136>
cmpl   $0x7,-0x84(%rbp)
jne    12df <main+0x1af>
mov    -0x7c(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ed <main+0x1bd>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xefa(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     11f3 <main+0xa3>
lea    0xe85(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe88(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%esi
test   %esi,%esi
je     11ac <main+0x5c>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1190 <main+0x40>
mov    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,-0x4(%rsp,%rbx,1)
je     1209 <main+0xb9>
cmpb   $0x0,-0x3(%rsp,%rbx,1)
je     120f <main+0xbf>
cmpb   $0x0,-0x2(%rsp,%rbx,1)
je     1215 <main+0xc5>
cmpb   $0x0,-0x1(%rsp,%rbx,1)
je     121b <main+0xcb>
cmpb   $0x0,(%rsp,%rbx,1)
je     121f <main+0xcf>
add    $0x5,%rbx
cmp    $0x68,%rbx
jne    11c0 <main+0x70>
mov    $0x64,%ebx
jmp    121f <main+0xcf>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    12a3 <main+0x153>
add    $0xfffffffffffffffc,%rbx
jmp    121f <main+0xcf>
add    $0xfffffffffffffffd,%rbx
jmp    121f <main+0xcf>
add    $0xfffffffffffffffe,%rbx
jmp    121f <main+0xcf>
add    $0xffffffffffffffff,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xddf(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1279 <main+0x129>
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x63,(%rsp,%rbx,1)
je     1287 <main+0x137>
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1260 <main+0x110>
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
jmp    1297 <main+0x147>
lea    0xda0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Introduceti numele intreg: \0A\00"
@.str.1 = [27 x i8] c"S-a inregistrat o eroare \0A\00"
@.str.2 = [20 x i8] c"Numele este: \0A %s \0A\00"
@.str.3 = [4 x i8] c"%c \00"
@.str.4 = [22 x i8] c"my len=%i strlen=%i \0A\00"
@.str.5 = [42 x i8] c"Am gasit caracterul, este pe pozitia %i \0A\00"
@.str.6 = [19 x i8] c"Nu exista, sorry \0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i8* @gets(i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %89
14: ; preds = %0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 0, i32* %4
br label %17
17: ; preds = %36, %14
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 100
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
br label %39
28: ; preds = %20
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %17
39: ; preds = %27, %17
store i32 0, i32* %4
br label %40
40: ; preds = %52, %39
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 100
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %43
br label %55
51: ; preds = %43
br label %52
52: ; preds = %51
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %40
55: ; preds = %50, %40
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
store i32 %57, i32* %5
%58 = load i32, i32* %4
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %58, i32 %60)
store i32 3, i32* %6
store i32 0, i32* %4
br label %62
62: ; preds = %76, %55
%63 = load i32, i32* %4
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%65 = call i32 @strlen(i8* %64)
%66 = icmp slt i32 %63, %65
br i1 %66, label %67, label %79
67: ; preds = %62
%68 = load i32, i32* %4
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 99
br i1 %73, label %74, label %75
74: ; preds = %67
store i32 7, i32* %6
br label %79
75: ; preds = %67
br label %76
76: ; preds = %75
%77 = load i32, i32* %4
%78 = add nsw i32 %77, 1
store i32 %78, i32* %4
br label %62
79: ; preds = %74, %62
%80 = load i32, i32* %6
%81 = icmp eq i32 %80, 7
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* %4
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %83)
br label %87
85: ; preds = %79
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %87
87: ; preds = %85, %82
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %89
89: ; preds = %87, %12
%90 = load i32, i32* %1
ret i32 %90
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"Numele este: \0A %s \0A\00"
@.str.3 = [4 x i8] c"%c \00"
@.str.4 = [22 x i8] c"my len=%i strlen=%i \0A\00"
@.str.5 = [42 x i8] c"Am gasit caracterul, este pe pozitia %i \0A\00"
@str = [28 x i8] c"Introduceti numele intreg: \00"
@str.8 = [18 x i8] c"Nu exista, sorry \00"
@str.9 = [26 x i8] c"S-a inregistrat o eroare \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i8* @gets(i8* %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
br label %76
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %10
10: ; preds = %8, %15
%11 = phi i64 [ 0, %8 ], [ %18, %15 ]
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = sext i8 %13 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, 100
br i1 %19, label %20, label %10
20: ; preds = %10, %15
br label %21
21: ; preds = %46, %20
%22 = phi i64 [ 0, %20 ], [ %47, %46 ]
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %49, label %26
26: ; preds = %21
%27 = add nuw nsw i64 %22, 1
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %49, label %31
31: ; preds = %26
%32 = add nuw nsw i64 %22, 2
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %49, label %36
36: ; preds = %31
%37 = add nuw nsw i64 %22, 3
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %36
%42 = add nuw nsw i64 %22, 4
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = add nuw nsw i64 %22, 5
%48 = icmp eq i64 %47, 100
br i1 %48, label %52, label %21
49: ; preds = %41, %36, %31, %26, %21
%50 = phi i64 [ %22, %21 ], [ %27, %26 ], [ %32, %31 ], [ %37, %36 ], [ %42, %41 ]
%51 = trunc i64 %50 to i32
br label %52
52: ; preds = %46, %49
%53 = phi i32 [ %51, %49 ], [ 100, %46 ]
%54 = call i32 @strlen(i8* %3)
%55 = call i32 @strlen(i8* %3)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %53, i32 %55)
%57 = call i32 @strlen(i8* %3)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %72
59: ; preds = %52, %64
%60 = phi i64 [ %65, %64 ], [ 0, %52 ]
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, 99
br i1 %63, label %69, label %64
64: ; preds = %59
%65 = add nuw nsw i64 %60, 1
%66 = call i32 @strlen(i8* %3)
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %65, %67
br i1 %68, label %59, label %72
69: ; preds = %59
%70 = trunc i64 %60 to i32
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %70)
br label %74
72: ; preds = %64, %52
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %74
74: ; preds = %72, %69
%75 = call i32 @putchar(i32 10)
br label %76
76: ; preds = %74, %6
%77 = phi i32 [ -1, %6 ], [ 0, %74 ]
ret i32 %77
}