#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 *, ...);
int printStringWLen(char *array, int *length) {
  if (array[0] == '\0') {
    printf("Error -- array is null");
    return 1;
  }
  int number = 0;
  while (array[number] != '\0') {
    number++;
  }
  *length = number;
  printf("You Entered:%s\n", array);
  printf("The Length of the string is: %d\n", *length);
  return 0;
}


x86 assembly (clang, -O0):
<printStringWLen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114a <printStringWLen+0x3a>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11aa <printStringWLen+0x9a>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1174 <printStringWLen+0x64>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <printStringWLen+0x41>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStringWLen>:
push   %rbp
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     114f <printStringWLen+0x3f>
mov    %rsi,%rbx
mov    %rdi,%rsi
xor    %eax,%eax
cmpb   $0x0,0x1(%rsi,%rax,1)
lea    0x1(%rax),%rax
jne    1120 <printStringWLen+0x10>
mov    %eax,(%rbx)
lea    0xee3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%esi
lea    0xee1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1162 <printStringWLen+0x52>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Error -- array is null\00"
@.str.1 = [16 x i8] c"You Entered:%s\0A\00"
@.str.2 = [33 x i8] c"The Length of the string is: %d\0A\00"
define i32 @printStringWLen(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %34
14: ; preds = %2
store i32 0, i32* %6
br label %15
15: ; preds = %23, %14
%16 = load i8*, i8** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %15
26: ; preds = %15
%27 = load i32, i32* %6
%28 = load i32*, i32** %5
store i32 %27, i32* %28
%29 = load i8*, i8** %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %32)
store i32 0, i32* %3
br label %34
34: ; preds = %26, %12
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [23 x i8] c"Error -- array is null\00"
@.str.1 = [16 x i8] c"You Entered:%s\0A\00"
@.str.2 = [33 x i8] c"The Length of the string is: %d\0A\00"
define i32 @printStringWLen(i8* %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %18
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 1, %2 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = add nuw i64 %8, 1
br i1 %11, label %13, label %7
13: ; preds = %7
%14 = trunc i64 %8 to i32
store i32 %14, i32* %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = load i32, i32* %1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %13, %5
%19 = phi i32 [ 1, %5 ], [ 0, %13 ]
ret i32 %19
}