#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 strlen(char *);
void PrintSecretWordHided(char MotSecret[], char Discover[]) {
  char i = 0;
  printf("Mot Secret: ");
  for (i = 0; i < strlen(MotSecret); i++) {
    if (Discover[i] == 1) {
      printf("%c", MotSecret[i]);
    } else {
      printf("*");
    }
  }
}


x86 assembly (clang, -O0):
<PrintSecretWordHided>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jge    11bc <PrintSecretWordHided+0x9c>
mov    -0x10(%rbp),%rax
movsbq -0x11(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    119c <PrintSecretWordHided+0x7c>
mov    -0x8(%rbp),%rax
movsbq -0x11(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11aa <PrintSecretWordHided+0x8a>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11af <PrintSecretWordHided+0x8f>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1146 <PrintSecretWordHided+0x26>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintSecretWordHided>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %al,%al
jle    118d <PrintSecretWordHided+0x5d>
xor    %ebx,%ebx
jmp    117a <PrintSecretWordHided+0x4a>
nopl   0x0(%rax)
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
movsbq %al,%rax
cmp    %rax,%rbx
jge    118d <PrintSecretWordHided+0x5d>
mov    $0x2a,%edi
cmpb   $0x1,(%r14,%rbx,1)
jne    1160 <PrintSecretWordHided+0x30>
movsbl (%r15,%rbx,1),%edi
jmp    1160 <PrintSecretWordHided+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Mot Secret: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"*\00"
define void @PrintSecretWordHided(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %5
br label %7
7: ; preds = %33, %2
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = load i8*, i8** %3
%11 = call signext i8 @strlen(i8* %10)
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %36
14: ; preds = %7
%15 = load i8*, i8** %4
%16 = load i8, i8* %5
%17 = sext i8 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i8*, i8** %3
%24 = load i8, i8* %5
%25 = sext i8 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %32
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %22
br label %33
33: ; preds = %32
%34 = load i8, i8* %5
%35 = add i8 %34, 1
store i8 %35, i8* %5
br label %7
36: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Mot Secret: \00"
define void @PrintSecretWordHided(i8* %0, i8* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = tail call signext i8 @strlen(i8* %0)
%5 = icmp sgt i8 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %2, %15
%7 = phi i64 [ %18, %15 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 %7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
br label %15
15: ; preds = %6, %11
%16 = phi i32 [ %14, %11 ], [ 42, %6 ]
%17 = tail call i32 @putchar(i32 %16)
%18 = add nuw nsw i64 %7, 1
%19 = tail call signext i8 @strlen(i8* %0)
%20 = sext i8 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %6, label %22
22: ; preds = %15, %2
ret void
}