#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*/ assert(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
size_t snprintf(char *, size_t, char const *, char *, int);
int strlen(char const *);
int /*<<< orphan*/ write(int, char *, size_t);
void subunit_progress_sign(int fd, int n, char *sign) {
  char *buf;
  const char *fmt = "progress: %s%d\n";
  size_t sz = 1 + strlen(fmt) + 100;
  size_t l;
  buf = (char *)malloc(sz);
  l = snprintf(buf, sz, fmt, sign, n);
  assert(l < sz);
  write(fd, buf, l);
  free(buf);
}


x86 assembly (clang, -O0):
<subunit_progress_sign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
add    $0x64,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8d
call   1060 <snprintf@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <write@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subunit_progress_sign>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %esi,%r13d
mov    %edi,%r14d
lea    0xe85(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
add    $0x65,%eax
movslq %eax,%rbx
mov    %rbx,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13d,%r8d
call   1060 <snprintf@plt>
mov    %rax,%r15
xor    %edi,%edi
cmp    %rbx,%rax
setb   %dil
call   1070 <assert@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1040 <write@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"progress: %s%d\0A\00"
define void @subunit_progress_sign(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %8
%11 = load i8*, i8** %8
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 1, %12
%14 = add nsw i32 %13, 100
%15 = sext i32 %14 to i64
store i64 %15, i64* %9
%16 = load i64, i64* %9
%17 = call i64 @malloc(i64 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = load i64, i64* %9
%21 = load i8*, i8** %8
%22 = load i8*, i8** %6
%23 = load i32, i32* %5
%24 = call i64 @snprintf(i8* %19, i64 %20, i8* %21, i8* %22, i32 %23)
store i64 %24, i64* %10
%25 = load i64, i64* %10
%26 = load i64, i64* %9
%27 = icmp ult i64 %25, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i32, i32* %4
%31 = load i8*, i8** %7
%32 = load i64, i64* %10
%33 = call i32 @write(i32 %30, i8* %31, i64 %32)
%34 = load i8*, i8** %7
%35 = call i32 @free(i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"progress: %s%d\0A\00"
define void @subunit_progress_sign(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = add nsw i32 %4, 101
%6 = sext i32 %5 to i64
%7 = tail call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @snprintf(i8* %8, i64 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
%10 = icmp ult i64 %9, %6
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @write(i32 %0, i8* %8, i64 %9)
%14 = tail call i32 @free(i8* %8)
ret void
}