#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*/ insert_char(char, int);
void put_tabs(int col, int w) {
  int n_tabs = (w + col % 8) / 8;
  int n_spaces = (n_tabs == 0) ? w : (w + col) % 8;
  insert_char('\t', n_tabs);
  insert_char(' ', n_spaces);
}


x86 assembly (clang, -O0):
<put_tabs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1154 <put_tabs+0x44>
mov    -0x8(%rbp),%edx
mov    %edx,-0x18(%rbp)
jmp    1165 <put_tabs+0x55>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x9,%edi
call   1030 <insert_char@plt>
mov    -0x10(%rbp),%esi
mov    $0x20,%edi
call   1030 <insert_char@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_tabs>:
push   %rbx
mov    %esi,%ebx
lea    0x7(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffff8,%eax
mov    %edi,%ecx
sub    %eax,%ecx
lea    (%rbx,%rcx,1),%edx
add    $0x7,%edx
mov    %ecx,%eax
add    %esi,%eax
cmp    $0xf,%edx
jb     1145 <put_tabs+0x35>
lea    (%rbx,%rdi,1),%ecx
add    $0x7,%ecx
mov    %ebx,%edx
add    %edi,%edx
cmovns %edx,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%edx
mov    %edx,%ebx
lea    0x7(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0x3,%esi
mov    $0x9,%edi
call   1030 <insert_char@plt>
mov    $0x20,%edi
mov    %ebx,%esi
pop    %rbx
jmp    1030 <insert_char@plt>

LLVM IR (-O0):
define void @put_tabs(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = srem i32 %8, 8
%10 = add nsw i32 %7, %9
%11 = sdiv i32 %10, 8
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32, i32* %4
br label %21
16: ; preds = %2
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = add nsw i32 %17, %18
%20 = srem i32 %19, 8
br label %21
21: ; preds = %16, %14
%22 = phi i32 [ %15, %14 ], [ %20, %16 ]
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = call i32 @insert_char(i8 signext 9, i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @insert_char(i8 signext 32, i32 %25)
ret void
}

LLVM IR (-O2):
define void @put_tabs(i32 %0, i32 %1) {
%3 = srem i32 %0, 8
%4 = add nsw i32 %3, %1
%5 = add i32 %4, 7
%6 = icmp ult i32 %5, 15
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = add nsw i32 %1, %0
%9 = srem i32 %8, 8
br label %10
10: ; preds = %2, %7
%11 = phi i32 [ %9, %7 ], [ %1, %2 ]
%12 = sdiv i32 %4, 8
%13 = tail call i32 @insert_char(i8 signext 9, i32 %12)
%14 = tail call i32 @insert_char(i8 signext 32, i32 %11)
ret void
}