#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*/ bputc(char *, int *, char);
scalar_t__ strlen(char *);
void bputs(char *msg, int *len, char *s, int fld) {
  for (fld -= (int)strlen(s); fld > 0; fld--)
    bputc(msg, len, ' ');
  while (*s)
    bputc(msg, len, *(s++));
}


x86 assembly (clang, -O0):
<bputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1174 <bputs+0x54>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1030 <bputc@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <bputs+0x2a>
jmp    1179 <bputs+0x59>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11aa <bputs+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edx
call   1030 <bputc@plt>
jmp    1179 <bputs+0x59>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bputs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
jle    1168 <bputs+0x48>
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1030 <bputc@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1150 <bputs+0x30>
mov    (%rbx),%al
test   %al,%al
je     1199 <bputs+0x79>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <bputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <bputs+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bputs(i8* %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %7
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
%12 = load i32, i32* %8
%13 = sub nsw i32 %12, %11
store i32 %13, i32* %8
br label %14
14: ; preds = %21, %4
%15 = load i32, i32* %8
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i32*, i32** %6
%20 = call i32 @bputc(i8* %18, i32* %19, i8 signext 32)
br label %21
21: ; preds = %17
%22 = load i32, i32* %8
%23 = add nsw i32 %22, -1
store i32 %23, i32* %8
br label %14
24: ; preds = %14
br label %25
25: ; preds = %29, %24
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = load i32*, i32** %6
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %7
%34 = load i8, i8* %32
%35 = call i32 @bputc(i8* %30, i32* %31, i8 signext %34)
br label %25
36: ; preds = %25
ret void
}

LLVM IR (-O2):
define void @bputs(i8* %0, i32* %1, i8* nocapture %2, i32 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = trunc i64 %5 to i32
%7 = sub nsw i32 %3, %6
%8 = icmp sgt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %12, %4
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
br i1 %11, label %24, label %17
12: ; preds = %4, %12
%13 = phi i32 [ %15, %12 ], [ %7, %4 ]
%14 = tail call i32 @bputc(i8* %0, i32* %1, i8 signext 32)
%15 = add nsw i32 %13, -1
%16 = icmp ugt i32 %13, 1
br i1 %16, label %12, label %9
17: ; preds = %9, %17
%18 = phi i8 [ %22, %17 ], [ %10, %9 ]
%19 = phi i8* [ %20, %17 ], [ %2, %9 ]
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = tail call i32 @bputc(i8* %0, i32* %1, i8 signext %18)
%22 = load i8, i8* %20
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %17
24: ; preds = %17, %9
ret void
}