#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*/ gap(int);
int /*<<< orphan*/ off(int);
int /*<<< orphan*/ on(int);
void speak(int fd, const char *code) {
  int first = 1;
  while (*code != '\0') {
    if (!first)
      gap(1);
    else
      first = 0;
    on(fd);
    gap(*code == '.' ? 1 : 3);
    off(fd);
    code++;
  }
}


x86 assembly (clang, -O0):
<speak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b3 <speak+0x83>
cmpl   $0x0,-0x14(%rbp)
jne    116f <speak+0x3f>
mov    $0x1,%edi
call   1030 <gap@plt>
jmp    1176 <speak+0x46>
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <on@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x3,%edi
mov    $0x1,%eax
cmp    $0x2e,%ecx
cmove  %eax,%edi
call   1030 <gap@plt>
mov    -0x4(%rbp),%edi
call   1040 <off@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1146 <speak+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speak>:
push   %rbp
push   %rbx
push   %rax
cmpb   $0x0,(%rsi)
je     11a5 <speak+0x75>
mov    %rsi,%rbx
mov    %edi,%ebp
call   1050 <on@plt>
xor    %eax,%eax
cmpb   $0x2e,(%rbx)
setne  %al
lea    (%rax,%rax,1),%edi
add    $0x1,%edi
call   1030 <gap@plt>
mov    %ebp,%edi
call   1040 <off@plt>
cmpb   $0x0,0x1(%rbx)
je     11a5 <speak+0x75>
add    $0x2,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <gap@plt>
mov    %ebp,%edi
call   1050 <on@plt>
xor    %eax,%eax
cmpb   $0x2e,-0x1(%rbx)
setne  %al
lea    (%rax,%rax,1),%edi
add    $0x1,%edi
call   1030 <gap@plt>
mov    %ebp,%edi
call   1040 <off@plt>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <speak+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @speak(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 1, i32* %5
br label %6
6: ; preds = %17, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %6
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @gap(i32 1)
br label %17
16: ; preds = %11
store i32 0, i32* %5
br label %17
17: ; preds = %16, %14
%18 = load i32, i32* %3
%19 = call i32 @on(i32 %18)
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 1, i32 3
%26 = call i32 @gap(i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @off(i32 %27)
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
br label %6
31: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @speak(i32 %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %27, label %5
5: ; preds = %2
%6 = tail call i32 @on(i32 %0)
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 46
%9 = select i1 %8, i32 1, i32 3
%10 = tail call i32 @gap(i32 %9)
%11 = tail call i32 @off(i32 %0)
%12 = getelementptr inbounds i8, i8* %1, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %5, %15
%16 = phi i8* [ %24, %15 ], [ %12, %5 ]
%17 = tail call i32 @gap(i32 1)
%18 = tail call i32 @on(i32 %0)
%19 = load i8, i8* %16
%20 = icmp eq i8 %19, 46
%21 = select i1 %20, i32 1, i32 3
%22 = tail call i32 @gap(i32 %21)
%23 = tail call i32 @off(i32 %0)
%24 = getelementptr inbounds i8, i8* %16, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %15
27: ; preds = %15, %5, %2
ret void
}