#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 char *String;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int MAXPATHLEN;
int /*<<< orphan*/ XtGetApplicationNameAndClass(int /*<<< orphan*/ *, char **,
                                                char **);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
extern void _SG_warning(Display *dpy, char *format, char *p1, char *p2,
                        char *p3, char *p4) {
  char pch[MAXPATHLEN];
  String name = "UNKNOWN PROGRAM", class = "UNKNOWN CLASS";
  XtGetApplicationNameAndClass(dpy, &name, &class);
  sprintf(pch, format, p1, p2, p3, p4);
  fprintf(stderr, "%s (%s): %s\n", name, class, pch);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<_SG_warning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
lea    0xe6d(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe72(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1050 <XtGetApplicationNameAndClass@plt>
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1060 <sprintf@plt>
mov    -0x58(%rbp),%r8
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xe32(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_SG_warning>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,-0x40(%rbp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r14
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe7e(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <XtGetApplicationNameAndClass@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    -0x40(%rbp),%r9
call   1060 <sprintf@plt>
mov    0x2e1b(%rip),%r14
mov    (%r14),%edi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe4f(%rip),%rsi
mov    %rbx,%r8
call   1030 <fprintf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [16 x i8] c"UNKNOWN PROGRAM\00"
@.str.1 = [14 x i8] c"UNKNOWN CLASS\00"
@stderr = global i32 0
@.str.2 = [13 x i8] c"%s (%s): %s\0A\00"
define void @_SG_warning(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%17 = load i32, i32* @MAXPATHLEN
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %13
%20 = alloca i8, i64 %18
store i64 %18, i64* %14
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %15
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %16
%21 = load i32*, i32** %7
%22 = call i32 @XtGetApplicationNameAndClass(i32* %21, i8** %15, i8** %16)
%23 = load i8*, i8** %8
%24 = load i8*, i8** %9
%25 = load i8*, i8** %10
%26 = load i8*, i8** %11
%27 = load i8*, i8** %12
%28 = call i32 @sprintf(i8* %20, i8* %23, i8* %24, i8* %25, i8* %26, i8* %27)
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %15
%31 = load i8*, i8** %16
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %31, i8* %20)
%33 = load i32, i32* @stderr
%34 = call i32 @fflush(i32 %33)
%35 = load i8*, i8** %13
ret void
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@.str = [16 x i8] c"UNKNOWN PROGRAM\00"
@.str.1 = [14 x i8] c"UNKNOWN CLASS\00"
@stderr = global i32 0
@.str.2 = [13 x i8] c"%s (%s): %s\0A\00"
define void @_SG_warning(i32* %0, i8* nocapture %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = load i32, i32* @MAXPATHLEN
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = bitcast i8** %7 to i8*
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %7
%13 = bitcast i8** %8 to i8*
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %8
%14 = call i32 @XtGetApplicationNameAndClass(i32* %0, i8** %7, i8** %8)
%15 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) %1, i8* %2, i8* %3, i8* %4, i8* %5)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %18, i8* %11)
%20 = load i32, i32* @stderr
%21 = call i32 @fflush(i32 %20)
ret void
}