#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 */
struct SocketBuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ buffWrite(char *, int, struct SocketBuffer *);
void writeString(char *string, struct SocketBuffer *buff) {
  int size = 0;
  int strChar = string[0];
  while (strChar != '\0') {
    size++;
    strChar = string[size];
  }
  size++;
  buffWrite(string, size, buff);
}


x86 assembly (clang, -O0):
<writeString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1158 <writeString+0x48>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <writeString+0x21>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <buffWrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeString>:
mov    %rsi,%rdx
cmpb   $0x0,(%rdi)
je     1131 <writeString+0x21>
mov    $0x1,%esi
nopl   (%rax)
movslq %esi,%rax
lea    0x1(%rax),%esi
cmpb   $0x0,(%rdi,%rax,1)
jne    1120 <writeString+0x10>
jmp    1030 <buffWrite@plt>
mov    $0x1,%esi
jmp    1030 <buffWrite@plt>

LLVM IR (-O0):
%struct.SocketBuffer = type { i32 }
define void @writeString(i8* %0, %struct.SocketBuffer* %1) {
%3 = alloca i8*
%4 = alloca %struct.SocketBuffer*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store %struct.SocketBuffer* %1, %struct.SocketBuffer** %4
store i32 0, i32* %5
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %6
br label %11
11: ; preds = %14, %2
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %6
br label %11
23: ; preds = %11
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = load %struct.SocketBuffer*, %struct.SocketBuffer** %4
%29 = call i32 @buffWrite(i8* %26, i32 %27, %struct.SocketBuffer* %28)
ret void
}

LLVM IR (-O2):
%struct.SocketBuffer = type { i32 }
define void @writeString(i8* %0, %struct.SocketBuffer* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %9, %5 ], [ 1, %2 ]
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = add i32 %6, 1
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %2
%13 = phi i32 [ 1, %2 ], [ %9, %5 ]
%14 = tail call i32 @buffWrite(i8* %0, i32 %13, %struct.SocketBuffer* %1)
ret void
}