#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*/ snprintf(char *, int, char *, ...);
void foo(char *a, char *b, char *c, int d, int e) {
  snprintf(a, 7, "abc\\\123 efg");
  d &= 63;
  d += 10;
  snprintf(b, 7, "a%dbcdefg", d);
  e &= 127;
  snprintf(c, 7, "a%dbcdefgh", e);
}


x86 assembly (clang, -O0):
<foo>:
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    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x7,%esi
lea    0xec5(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x1c(%rbp),%eax
and    $0x3f,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    $0x7,%esi
lea    0xea3(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x20(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    $0x7,%esi
lea    0xe8a(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xed7(%rip),%rdx
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
and    $0x3f,%ebp
add    $0xa,%ebp
lea    0xec8(%rip),%rdx
mov    %r15,%rdi
mov    $0x7,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
and    $0x7f,%ebx
lea    0xeb7(%rip),%rdx
mov    %r14,%rdi
mov    $0x7,%esi
mov    %ebx,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"abc\\S efg\00"
@.str.1 = [10 x i8] c"a%dbcdefg\00"
@.str.2 = [11 x i8] c"a%dbcdefgh\00"
define void @foo(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %9
%14 = and i32 %13, 63
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = add nsw i32 %15, 10
store i32 %16, i32* %9
%17 = load i8*, i8** %7
%18 = load i32, i32* %9
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %17, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %10
%21 = and i32 %20, 127
store i32 %21, i32* %10
%22 = load i8*, i8** %8
%23 = load i32, i32* %10
%24 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %22, i32 7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"abc\\S efg\00"
@.str.1 = [10 x i8] c"a%dbcdefg\00"
@.str.2 = [11 x i8] c"a%dbcdefgh\00"
define void @foo(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = and i32 %3, 63
%8 = add nuw nsw i32 %7, 10
%9 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = and i32 %4, 127
%11 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %2, i32 7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret void
}