#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int _char(char);
int /*<<< orphan*/ _led_display(int, int *);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
void _led_puts(int fd, char *s) {
  uint8_t buf[4];
  char *p = s;
  int i = 0;
  memset(buf, 0, sizeof(buf));
  for (i = 0, p = s; *p != '\0' && i < 4; p++) {
    if (*p == '.' && i == 0)
      buf[i++] = 0x80;
    else if (*p == '.' && i > 0)
      buf[i - 1] |= 0x80;
    else
      buf[i++] = _char(*p);
  }
  _led_display(fd, buf);
}


x86 assembly (clang, -O0):
<_led_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     118c <_led_puts+0x5c>
cmpl   $0x4,-0x2c(%rbp)
setl   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    119c <_led_puts+0x6c>
jmp    123f <_led_puts+0x10f>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11d0 <_led_puts+0xa0>
cmpl   $0x0,-0x2c(%rbp)
jne    11d0 <_led_puts+0xa0>
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
cltq
movl   $0x80,-0x20(%rbp,%rax,4)
jmp    1229 <_led_puts+0xf9>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1205 <_led_puts+0xd5>
cmpl   $0x0,-0x2c(%rbp)
jle    1205 <_led_puts+0xd5>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%ecx
or     $0x80,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    1224 <_led_puts+0xf4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1050 <_char@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    1229 <_led_puts+0xf9>
jmp    122e <_led_puts+0xfe>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    116d <_led_puts+0x3d>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <_led_display@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_led_puts>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     11c1 <_led_puts+0x91>
add    $0x1,%rbx
nopl   0x0(%rax)
cmp    $0x2e,%al
jne    1180 <_led_puts+0x50>
test   %ebp,%ebp
jne    1180 <_led_puts+0x50>
movl   $0x80,(%rsp)
mov    $0x1,%ebp
jmp    11b1 <_led_puts+0x81>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2e,%al
jne    11a0 <_led_puts+0x70>
test   %ebp,%ebp
jle    11a0 <_led_puts+0x70>
lea    -0x1(%rbp),%eax
orb    $0x80,(%rsp,%rax,4)
jmp    11b1 <_led_puts+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <_char@plt>
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %eax,(%rsp,%rcx,4)
movzbl (%rbx),%eax
test   %al,%al
je     11c1 <_led_puts+0x91>
add    $0x1,%rbx
cmp    $0x4,%ebp
jl     1160 <_led_puts+0x30>
mov    %rsp,%rsi
mov    %r14d,%edi
call   1030 <_led_display@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @_led_puts(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [4 x i32]
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
store i8* %8, i8** %6
store i32 0, i32* %7
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%10 = call i32 @memset(i32* %9, i32 0, i32 16)
store i32 0, i32* %7
%11 = load i8*, i8** %4
store i8* %11, i8** %6
br label %12
12: ; preds = %60, %2
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 4
br label %20
20: ; preds = %17, %12
%21 = phi i1 [ false, %12 ], [ %19, %17 ]
br i1 %21, label %22, label %63
22: ; preds = %20
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 46
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %33
store i32 128, i32* %34
br label %59
35: ; preds = %27, %22
%36 = load i8*, i8** %6
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 46
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i32, i32* %7
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = or i32 %48, 128
store i32 %49, i32* %47
br label %58
50: ; preds = %40, %35
%51 = load i8*, i8** %6
%52 = load i8, i8* %51
%53 = call i32 @_char(i8 signext %52)
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %56
store i32 %53, i32* %57
br label %58
58: ; preds = %50, %43
br label %59
59: ; preds = %58, %30
br label %60
60: ; preds = %59
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %6
br label %12
63: ; preds = %20
%64 = load i32, i32* %3
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%66 = call i32 @_led_display(i32 %64, i32* %65)
ret void
}

LLVM IR (-O2):
define void @_led_puts(i32 %0, i8* nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%6 = call i32 @memset(i32* %5, i32 0, i32 16)
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %38, label %9
9: ; preds = %2, %31
%10 = phi i8 [ %34, %31 ], [ %7, %2 ]
%11 = phi i32 [ %32, %31 ], [ 0, %2 ]
%12 = phi i8* [ %33, %31 ], [ %1, %2 ]
%13 = icmp eq i8 %10, 46
%14 = icmp eq i32 %11, 0
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %17
16: ; preds = %9
store i32 128, i32* %5
br label %31
17: ; preds = %9
%18 = icmp sgt i32 %11, 0
%19 = select i1 %13, i1 %18, i1 false
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = add nsw i32 %11, -1
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = or i32 %24, 128
store i32 %25, i32* %23
br label %31
26: ; preds = %17
%27 = call i32 @_char(i8 signext %10)
%28 = add nsw i32 %11, 1
%29 = sext i32 %11 to i64
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %29
store i32 %27, i32* %30
br label %31
31: ; preds = %16, %26, %20
%32 = phi i32 [ 1, %16 ], [ %11, %20 ], [ %28, %26 ]
%33 = getelementptr inbounds i8, i8* %12, i64 1
%34 = load i8, i8* %33
%35 = icmp ne i8 %34, 0
%36 = icmp slt i32 %32, 4
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %9, label %38
38: ; preds = %31, %2
%39 = call i32 @_led_display(i32 %0, i32* %5)
ret void
}